qwertyui:QWERTYUI

public class Solution { public string IntToRoman(int num) { string[][] roman = new string[][]{ new string[]{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}, new string[]{"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}, new string[]{"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}, new string[]{"", "M", "MM", "MMM"} }; string result = ""; int digit = 0; while (num != 0) { int remain = num % 10; result = roman[digit][remain] + result; digit++; num /= 10; } return result; }}

相关推荐

相关文章