12 Integer to Roman(int转罗马数字Medium)
题目意思:1-3999转罗马数字
思路:从大往小减
ps:这题有点蛋疼
class Solution {
public:
string intToRoman(int num) {
string a[]={"I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"};
int b[]={,,,,,,,,,,,,};
string str="";
for(int i=;i>=;--i){
while(num>=b[i]){
str+=a[i];
num=num-b[i];
}
}
return str;
}
};
12 Integer to Roman(int转罗马数字Medium)的更多相关文章
- [LeetCode] 12. Integer to Roman 整数转为罗马数字
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 ...
- 【LeetCode】12. Integer to Roman 整数转罗马数字
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:roman, 罗马数字,题解,leetcode, 力扣, ...
- [leetcode]12. Integer to Roman整数转罗马数字
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 ...
- Leetcode 12. Integer to Roman(打表,水)
12. Integer to Roman Medium Roman numerals are represented by seven different symbols: I, V, X, L, C ...
- Leetcode 12——Integer to Roman
12.Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be withi ...
- leetCode练题——12. Integer to Roman
1.题目 12. Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C, ...
- lintcode :Integer to Roman 整数转罗马数字
题目 整数转罗马数字 给定一个整数,将其转换成罗马数字. 返回的结果要求在1-3999的范围内. 样例 4 -> IV 12 -> XII 21 -> XXI 99 -> XC ...
- 《LeetBook》leetcode题解(12):Integer to Roman[M]
我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...
- 【LeetCode】12. Integer to Roman (2 solutions)
Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...
随机推荐
- 【gm】
gm : GraphicsMagick for node.js aheckmann/gm imgAreaSelect 图片剪裁 apt-get install imagemagick 执行conver ...
- Spfa费用流模板
; ,maxm=; ,fir[maxn],nxt[maxm],to[maxm]; int cap[maxm],val[maxm],dis[maxn],path[maxn]; void add(int ...
- How to Implement the IContextMenu Interface
http://msdn.microsoft.com/en-us/library/windows/desktop/hh127443(v=vs.85).aspx IContextMenu is the m ...
- STUCTS LABLE ‘S BENEFIT
{LJ?Dragon}[注]Struts标签的三个好处 RELATED LINKS 0.UTF-8 有无BOM的区别 UTF-8 BOM 06. 几款网页数据抓取软件 SOFTWARE_INTRODU ...
- 2nd day
<?php //求数组的平均值 $a3 = array( array(11,12, 13), array(21,22,23, 24, 25), array(31,32,33, 35), arra ...
- 饿了么 ---Java面试
下午去饿了么参加面试,其实也满怀期待,毕竟也是个大公司. 交通:偏外环,真北路 环境:感觉压抑,不通风,面试人很多,可能是屋子高度低,不舒服. 填了资料,等待面试,两轮,真是憋屈 都是搞技术的,何苦为 ...
- Textview 文本旋转,倾斜
有时候Android自带的控件无法满足我们的某些要求,这时就需要我们自定义控件来实现这些功能.比如需要一个TextView里的字倾斜一定的角度,就需要自定义TextView. 代码如下: ? 1 2 ...
- iOS-获取UIView的全部层级结构
在iOS中获取UIView的全部层级结构 应用场景 在实际 iOS 开发中,非常多时候都须要知道某个 UI 控件中包括哪些子控件,而且分清楚它们的层级结构和自个的 frame 以及 bounds ,以 ...
- [转] STL源码学习----lower_bound和upper_bound算法
http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html PS: lower_bound of value 就是最后一个 < ...
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L(转)
09-09 10:19:59.979: E/AndroidRuntime(2767): FATAL EXCEPTION: main09-09 10:19:59.979: E/AndroidRuntim ...