• This is not beautiful code. But the thinking process is pretty clear. You can also make the code below more concise very easily.

If you know how the Roman Numeral works, it is very easy to deal with this question. Here are two good websites:

http://literacy.kent.edu/Minigrants/Cinci/romanchart.htm

http://number.webmasters.sk/roman.php

``````public String intToRoman(int num) {
// I1 V5 X10 L50 C100 D500 M1000
// 左一（4），右三（1-3），整（0，5）
int count = 0;
ArrayList<String> temp = new ArrayList();
ArrayList<String> res = new ArrayList();
// M1000
count = num / 1000;
num = num % 1000;
for (int i = 0; i < count; i++) {
}
// D500
/// 900 - 1000
if (num >= 900) {
num = num - 900;
} else {
/// 500 - 900
if (num >= 500) {
num = num - 500;
}
}
// C100
count = num / 100;
num = num % 100;
if (count == 4) {
} else {
for (int i = 0; i < count; i++) {
}
}
// L50
if (num >= 90) {
num = num - 90;
} else {
/// 50 - 90
if (num >= 50) {
num = num - 50;
}
}
// X10
count = num / 10;
num = num % 10;
if (count == 4) {
} else {
for (int i = 0; i < count; i++) {
}
}
// V5
if (num >= 9) {
num = num - 9;
} else {
/// 5 - 9
if (num >= 5) {
num = num - 5;
}
}
// I1
count = num;
num = num % 1;
if (count == 4) {
} else {
for (int i = 0; i < count; i++) {