题目意思: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)的更多相关文章

  1. [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 ...

  2. 【LeetCode】12. Integer to Roman 整数转罗马数字

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:roman, 罗马数字,题解,leetcode, 力扣, ...

  3. [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 ...

  4. Leetcode 12. Integer to Roman(打表,水)

    12. Integer to Roman Medium Roman numerals are represented by seven different symbols: I, V, X, L, C ...

  5. Leetcode 12——Integer to Roman

    12.Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be withi ...

  6. leetCode练题——12. Integer to Roman

    1.题目 12. Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C,  ...

  7. lintcode :Integer to Roman 整数转罗马数字

    题目 整数转罗马数字 给定一个整数,将其转换成罗马数字. 返回的结果要求在1-3999的范围内. 样例 4 -> IV 12 -> XII 21 -> XXI 99 -> XC ...

  8. 《LeetBook》leetcode题解(12):Integer to Roman[M]

    我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.g ...

  9. 【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 ...

随机推荐

  1. 【转】google chrome如何设置主页

    原文网址:http://jingyan.baidu.com/article/8275fc86bf916c46a13cf666.html google chrome是一款拥有众多优秀插件的浏览器,是我们 ...

  2. 图论(差分约束系统):POJ 1201 Intervals

    Intervals Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24099   Accepted: 9159 Descri ...

  3. dll文件已经引用,但using找不到命名空间

    一:问题截图 二:解决办法 1.没看到lz的代码中有Vancl.Server的dll. 2.确实有编译不过的问题,是Vancl.WindowsServices这个工程的target framework ...

  4. Uncle Sam 山姆大叔

    山姆大叔被用来代指“美国”或“美国政府”,主要在美国.英国,尤其是在新闻界中使用较多.“山姆大叔”是美国的绰号,它同自由女神一样,为世人所熟知. 形象 美国的报纸杂志.文学作品和漫画中,经常可以看到“ ...

  5. FATE(完全背包)

    /* http://acm.hdu.edu.cn/showproblem.php?pid=2159 分析: 和普通的完全背包没有什么太大的区别 但是题目中给出了限制最多可杀s个怪 用二维数组dp[i] ...

  6. zoj 2836 容斥原理

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2836 #include <cstdio> #incl ...

  7. SCOI2013 多项式的运算

    ---恢复内容开始--- 又是一道裸数据结构题. 之前受序列操作的蛋疼写法影响,只用一个tag,不知道怎么记,之后看了下别人的,终于领悟要用两个tag,一个add,一个mul,维护相当简单,想清楚就行 ...

  8. PHP学习之[第06讲]数组、多维数组和数组函数

    一.数组 ①Array(“aa”,12,true,2.2,”test”,50); ②Array(“title”=>“aa”,  ”age”=>20); 1.创建: $arr= array( ...

  9. Discuz X2.5 用户名包含被系统屏蔽的字符[解决方法]

    /uc_client/data/cache/badwords.php文件里的内容 删除并用 utf-8格式保存

  10. [ES6] Array.findIndex()

    In es5, you can use indexOf to get the index of one item in an array. In es6, you can use findIndex( ...