Given an integer, convert it to a roman numeral.

Input is guaranteed to be within the range from 1 to 3999.

     string intToRoman(int num) {
string res;
char a[]={'I','X','C','M'};
char b[]={'V','L','D'};
int i=,ld=,n=;
while(i>=)
{
ld=num/n;
num%=n;
n/=; switch(ld)
{
case :break;
case :{res+=a[i];break;}
case :{res=res+a[i]+a[i];break;}
case :{res=res+a[i]+a[i]+a[i];break;}
case :{res=res+a[i]+b[i];break;}
case :{res=res+b[i];break;}
case :{res=res+b[i]+a[i];break;}
case :{res=res+b[i]+a[i]+a[i];break;}
case :{res=res+b[i]+a[i]+a[i]+a[i];break;}
case :{res=res+a[i]+a[i+];break;}
default :break; }
i--; }
return res; }

Integer to Roman的更多相关文章

  1. 【LeetCode】Roman to Integer & Integer to Roman

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

  2. 【leetcode】Integer to Roman

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

  3. 【leetcode】Integer to Roman & Roman to Integer(easy)

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

  4. [LintCode] Integer to Roman 整数转化成罗马数字

    Given an integer, convert it to a roman numeral. The number is guaranteed to be within the range fro ...

  5. 5.Integer to Roman && Roman to Integer

    Roman chart: http://literacy.kent.edu/Minigrants/Cinci/romanchart.htm Integer to Roman Given an inte ...

  6. LeetCode:Roman to Integer,Integer to Roman

    首先简单介绍一下罗马数字,一下摘自维基百科 罗马数字共有7个,即I(1).V(5).X(10).L(50).C(100).D(500)和M(1000).按照下述的规则可以表示任意正整数.需要注意的是罗 ...

  7. 58. 分析、测试与总结:罗马数字和阿拉伯数字的转换[roman to integer and integer to roman in c++]

    [本文链接] http://www.cnblogs.com/hellogiser/p/roman-to-integer-and-integer-to-roman.html [题目] 给出一个罗马数字, ...

  8. No.012 Integer to Roman

    12. Integer to Roman Total Accepted: 71315 Total Submissions: 176625 Difficulty: Medium Given an int ...

  9. 【LeetCode】12 & 13 - Integer to Roman & Roman to Integer

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

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

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

随机推荐

  1. UVa 11361 - Investigating Div-Sum Property

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  2. [转载]Android View.onMeasure方法的理解

    2013-12-18 10:56:28 转载自http://blog.sina.com.cn/s/blog_61fbf8d10100zzoy.html View在屏幕上显示出来要先经过measure( ...

  3. Python标准库---子进程 (subprocess包)

    这里的内容以Linux进程基础和Linux文本流为基础.subprocess包主要功能是执行外部的命令和程序.比如说,我需要使用wget下载文件.我在Python中调用wget程序.从这个意义上来说, ...

  4. VC单文档对话框添加托盘图标

    一 单文档添加托盘 1. 在CMainFrame中定义NOTIFYICONDATA结构m_notify 2.在OnCreate中添加托盘初始化代码 int CMainFrame::OnCreate(L ...

  5. Linux下备份系统至另一硬盘

    首先会想到dd命令. 但,, 1,若是小硬盘还好,上T的大硬盘这样做肯定不明智; 2,况且dd是在硬件层面的拷贝,前面的MBR也会随之恢复到另一个盘,若源硬盘是100G,目标盘是200G,又会出问题, ...

  6. SharePoint 2013 企业搜索架构示例

    博客地址:http://blog.csdn.net/FoxDave 本文参考自微软官方的Chart,我们来看一下企业中对于不同规模SharePoint搜索的场的架构是什么样的. 对于搜索场的规模, ...

  7. C# WebBrowser NativeMethods

    using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using Syste ...

  8. IntelliJ IDEA 12.0

    User name:JavaDeveloper Serial number:92547-KY2BB-QZ0S1-PEZCV-HUT8Q-6RYY4

  9. js 弹出div窗口 可移动 可关闭 (转)

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  10. C#判断IP地址是否合法函数-使用正则表达式-2个 (转)

    public bool IsCorrenctIP(string ip){ string pattrn=@"(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2} ...