leetcode_c++: Integer to Roman(012)
2016-08-04 19:21
429 查看
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
Subscribe to see which companies asked this question
Show Tags
Show Similar Problems
十进制数转换为罗马数制
Input is guaranteed to be within the range from 1 to 3999.
Subscribe to see which companies asked this question
Show Tags
Show Similar Problems
十进制数转换为罗马数制
class Solution { public: string intToRoman(int num) { string symbol[] = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}; int value[] = {1000,900,500,400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; string result; for(int i=0; num!=0; i++){ while(num >= value[i]){ num -= value[i]; result+=symbol[i]; } } return result; } };
相关文章推荐
- 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 12 — Integer to Roman(C++ Java Python)
- LeetCode刷题(C++)——Integer to Roman(Medium)
- leetcode_c++:Roman to Integer(013)
- LeetCode刷题(C++)——Roman to Integer(Easy)
- LeetCode 012 Integer to Roman
- 【JAVA、C++】LeetCode 012 Integer to Roman
- [LeetCode]题解(python):012-Integer to Roman
- 【leetcode c++】13 Roman to Integer
- leetcode-012-Integer to Roman
- [C++]LeetCode: 85 Integer to Roman
- 【LeetCode-面试算法经典-Java实现】【012-Integer to Roman(数字转罗马字符)】
- leetcode 012 —— Integer to Roman
- LeetCode 012 Integer to Roman
- LeetCode上Roman to Integer的C++代码
- leetcode_13_Roman to Integer(C++)(easy)