Integer to Roman
Desicription
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
Solution
代码语言:javascript复制class Solution {
public:
string intToRoman(int num) {
string thousand[4] = {"", "M", "MM", "MMM"};
string hundred[10] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
string ten[10] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
string one[10] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
return thousand[num/1000] hundred[(num00)/100] ten[(num0)/10] one[num];
}
};