题目:
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
给定一个罗马数字,将其转换为整数,输入保证在从1到3999之间。
思路:
查看罗马数字表,I对应1,V对应5,X对应10,L对应50,C对应100,D对应500,M对应1000,罗马数计算规则为,相同的数字连写,表示的数等于这些数相加,但连续的数重复不能超过三次,比如说III = 3;当小的数在打的右边,所表示的数等于这些数字相加,VII = 7;当小的数在大的数左边(除I、X、C),所表示的数等于大的数减去小的数,IV = 4。