###### 13. Roman to Integer

Given a roman numeral, convert it to an integer.

Input is guaranteed to be within the range from 1 to 3999.

	public static int romanToInt(String s) {
int num = 0, pre = 0;
int res = 0;
for (int i = s.length() - 1; i >= 0; i--) {
num = romateCharToNum(s.charAt(i));
if (pre > num) {
res -= num;
} else {
res += num;
}
pre = num;
}
return res;
}

static int romateCharToNum(char c) {
switch (c) {
case 'I':
return 1;
case 'X':
return 10;
case 'C':
return 100;
case 'M':
return 1000;
case 'V':
return 5;
case 'L':
return 50;
case 'D':
return 500;
}
return 0;
}

#### LeetCode(13) RomanToInteger

2013-12-11 10:42:45

#### [LeetCode][13]Roman to Integer解析 罗马字符转int类型关于栈的常数实现-Java实现

2016-06-14 10:36:50

#### 13. Roman to Integer [easy] (Python)

2016-05-18 23:01:58

#### leetcode-java-13. Roman to Integer

2016-06-02 17:09:11

#### 【LeetCode013算法/编程练习C++】Roman to Integer //难得击败了80%的人

2016-12-29 19:37:13

#### [LeetCode] 013. Roman to Integer (Easy) (C++/Java/Python)

2015-03-02 23:19:35

#### [LeetCode]Roman to Integer,解题报告

2013-12-01 20:46:29

#### (Java)LeetCode-13. Roman to Integer

2016-05-10 23:27:14

#### LeetCode13——Roman to Integer

2015-01-27 17:51:09

#### Integer to Roman （罗马数字转换） 【leetcode】

2013-09-20 16:09:30

## 不良信息举报

13. Roman to Integer