Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
题意:把数字转换为罗马数字
感觉用c的话太麻烦了,所以用Python写了
1 class Solution(object): 2 def intToRoman(self, num): 3 """ 4 :type num: int 5 :rtype: str 6 """ 7 flag=[['','I','II','III','IV','V','VI','VII','VIII','IX'], 8 ['','X','XX','XXX','XL','L','LX','LXX','LXXX','XC'], 9 ['','C','CC','CCC','CD','D','DC','DCC','DCCC','CM'], 10 ['','M','MM','MMM']] 11 12 i = 0 13 s = '' 14 15 while num>0: 16 t = num%10 17 s = flag[i][t]+s 18 i+=1 19 num=num//10 20 21 return s