2017-09-09 LeetCode_012 Integer to Roman
2017-09-09 15:06
459 查看
12. Integer to Roman
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
solution:
2
3
4
5
6
7
8
9
10
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
solution:
class Solution {
2
public:
3
string intToRoman(int num) {
4
string m[4] = {"", "M", "MM", "MMM"},
5
c[10] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"},
6
x[10] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"},
7
i[10] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
8
return m[num/1000]+c[(num%1000)/100]+x[(num%100)/10]+i[num%10];
9
}
10
};
相关文章推荐
- LeetCode 012: Integer to Roman
- [LeetCode]012-Integer to Roman
- leetcode解题方案--012--Integer to Roman
- 【JAVA、C++】LeetCode 012 Integer to Roman
- leetcode 012 Integer to Roman
- LeetCode 012 Integer to Roman
- leetcode_c++: Integer to Roman(012)
- 2017-09-09 LeetCode_013 Roman to Integer
- LeetCode 012 Integer to Roman
- leetcode012 Integer to Roman
- [LeetCode]-012-Integer to Roman
- LeetCode 012 Integer to Roman
- LeetCode 012 Integer to Roman
- leetcode-012:Integer to Roman
- leetcode 012 —— Integer to Roman
- LeetCode 012 Integer to Roman
- 【LeetCode-面试算法经典-Java实现】【012-Integer to Roman(数字转罗马字符)】
- [LeetCode]题解(python):012-Integer to Roman
- Leetcode012 Integer to Roman
- leetcode012:Integer to Roman