LeetCode刷题(C++)——Integer to Roman(Medium)
来源:互联网 发布:c语言中putchar(10) 编辑:程序博客网 时间:2024/06/10 01:38
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
罗马数字:
1-9:{"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" }10-90:{"X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" }100-900:{"C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" }1000-3000:{"M", "MM", "MMM" }
class Solution {public: string intToRoman(int num) { string roman[][10] = { {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" },{"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" },{"","C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" },{"", "M", "MM", "MMM" } };string str;int i = 0;while (num){int j = num % 10;str = roman[i++][j] + str;num = num / 10;}return str; }};
1 0
- LeetCode刷题(C++)——Integer to Roman(Medium)
- 题解——Leetcode 12. Integer to Roman 难度:Medium
- [LeetCode] 012. Integer to Roman (Medium) (C++/Java/Python)
- LeetCode刷题(C++)——String to Integer (atoi)(Medium)
- LeetCode刷题(C++)——Roman to Integer(Easy)
- 【LeetCode】(12)Integer to Roman(Medium)
- LeetCode-12-Integer to Roman(哈希)-Medium
- Leetcode 12. Integer to Roman (Medium) (cpp)
- Leetcode OJ 12 Integer to Roman [Medium]
- leetcode— Integer to Roman
- leetcode系列(35)Roman to Integer & Integer to Roman
- 【leetcode】String——Roman to Integer(13)
- 刷LeetCode(12)——Integer to Roman
- 刷LeetCode(13)——Roman to Integer
- LeetCode 12 — Integer to Roman(C++ Java Python)
- LeetCode 13. Roman to Integer 题解(C++)
- LeetCode 12. Integer to Roman 题解(C++)
- 【LeetCode算法练习(C++)】Integer to Roman
- 设置html网页只能在微信中打开,并禁用分享功能
- ubuntu下g++报错 g++:command not found解决办法
- option操作
- 第六章 React props
- Java内部类_成员内部类_静态
- LeetCode刷题(C++)——Integer to Roman(Medium)
- 医院建立客户服务中心的必然性
- yii gridview 关联查询
- MySQL
- 聊一聊自定义标签
- SpringMVC jsp前台获取参数的方式 EL表达式
- 离散对数学习:baby_step_giant_step与ex_baby_step_giant_step算法
- css重置
- redis常用命令