摘要:
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.仔细理解罗马数的规则,把IVIX等也作为基本元素列入对应表中。然后每次选择能表示的最大值,把对应的字符串连起来。直到剩下的数=0为止。public class Solution { public String intToRoman(int num) { // Note: The Solution object is instantiated only once an... 阅读全文
posted @ 2013-10-09 22:41
果汁果粒
阅读(157)
评论(0)
推荐(0)
摘要:
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路:首先搞清楚罗马数的表示方式,百度百科告诉我们:基本字符IVXLCDM相应的阿拉伯数字表示为1510501005001000相同的数字连写,所表示的数等于这些数字相加得到的数,如:Ⅲ = 3;小的数字在大的数字的右边,所表示的数等于这些数字相加得到的数, 如:Ⅷ = 8;Ⅻ = 12;小的数字,(限于Ⅰ、X 和C)在大的数字的左边,所表示的数等于大数减小数得到的数,如:Ⅳ= 4;Ⅸ 阅读全文
posted @ 2013-10-09 22:37
果汁果粒
阅读(178)
评论(0)
推荐(0)