
1. 题目
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
2. 思路
计数规则:
- 若干相同数字连写表示的数是这些罗马数字的和,如 III=3;
- 小数字在大数字前面表示的数是用大数字减去小数字,如 IV=4;
- 小数字在大数字后面表示的数是用大数字加上小数字,如 VI=6;
1 |
public class { |

Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
计数规则:
1 |
public class { |
近期评论