题目意思: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. 【模拟】Codeforces 691B s-palindrome

    题目链接: http://codeforces.com/problemset/problem/691/B 题目大意: 求一个字符串是不是镜像的(不是回文).是输出TAK否则RE. 题目思路: [模拟] ...

  2. C# dll玩注入!.net运行时库内置!?

    Contents Introduction Back To Fundamentals Load The CLR Fundamentals Advanced DLL Injection Fundamen ...

  3. vijosP1194 Domino

    vijosP1194 Domino 链接:https://vijos.org/p/1194 [思路] 矩阵相乘. 参考Matrix67的文章: [代码] #include<cstdio> ...

  4. [后端Day1]Python2.7之基础

    注:以下内容全部为 廖雪峰的官方网站 中学习内容的摘要和总结 输入和输出: name = raw_input('please enter your name: ') print '100 + 200 ...

  5. hdoj 1513 Palindrome【LCS+滚动数组】

    Palindrome Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  6. linux —— 学习笔记(软件操作:安装、卸载、执行)

    目录: 0.相关基本命令    1.安装软件    2.卸载软件    3.打开软件  0.相关基本命令 与软件操作相关的主要命令有:dpkg  和 apt-get . dpkg   : “dpkg ...

  7. AS3 读写 C++ 64位数字

    为框架添加了一套新的与C++通讯的数据协议,其中和C++的大爷们对于他们的64位数字(unsigned long long)读写的问题纠结了很久.真心觉得“学好C++走遍天下都不怕啊” AS里Numb ...

  8. 【微信公众号】将微信公众号消息里的FromUserName即OpenID转成UnionID

    最近在调试微信公众号开发者模式,处理公众号消息,收到如下回调消息内容 <xml><ToUserName><![CDATA[gh_29********21]]>< ...

  9. Zlib文件压缩和解压

    开源代码:http://www.zlib.net/zlib使用手册:http://www.zlib.net/manual.htmlzlib wince版:http://www.tenik.co.jp/ ...

  10. CF 19D Points 【线段树+平衡树】

    在平面上进行三种操作: 1.add x y:在平面上添加一个点(x,y) 2.remove x y:将平面上的点(x,y)删除 3.find x y:在平面上寻找一个点,使这个点的横坐标大于x,纵坐标 ...