题目:
思路:
https://blog.csdn.net/m0_71120708/article/details/128769894
代码:
public String intToRoman(int num) {String[] thousands = new String[] {"", "M", "MM", "MMM"};String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};StringBuilder stringBuilder = new StringBuilder();stringBuilder.append(thousands[num / 1000]);stringBuilder.append(hundreds[num % 1000 / 100]);stringBuilder.append(tens[num % 100 / 10]);stringBuilder.append(ones[num % 10]);return stringBuilder.toString();}