public String intToRoman(int num) {
int[] values={1000,900,500,400,100,90,50,40,10,9,5,4,1};
String[] roman={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
String result="";
for(int i=0;i<values.length;i++)
{
while(num-values[i]>=0)
{
num-=values[i];
result+=roman[i];
} }
return result;
}

Integer to Roman(JAVA)的更多相关文章

  1. 12. Integer to Roman (JAVA)

    Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 ...

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

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

  3. LeetCode: Integer to Roman 解题报告

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

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

  5. 【leetcode】Integer to Roman

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

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

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

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

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

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

  9. LeetCode:Roman to Integer,Integer to Roman

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

随机推荐

  1. animation与transition

    animation 动画,无法直接决定开始时间 demo1 @-webkit-keyframes demo-animation1{ 0% { -webkit-transform:translate3d ...

  2. 关于scrollTop

    如下图

  3. NFinal ajax

    AJAX返回 我们经常会用到ajax,当我们想返回json时,需要这样写. context.Response.ContentType="application/json"; con ...

  4. 怎么改变Android手机里面文件的打开方式?包括文件管理器或者需要用到文件的APP

    工具-程序-qq-清除默认设置 设置>程序与功能>默认

  5. Spring mvc中@RequestMapping 6个基本用法整理

    继续整理,这个是前段时间用jsp开发的一个站点,说起来php程序员去做jsp程序确实有些小不适应,但是弄完后绝对对于这种强类型语言而比收获还是颇多的. 1,最基本的,方法级别上应用 @RequestM ...

  6. UVALive 4119 Always an integer (差分数列,模拟)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Always an integer Time Limit:3000MS     M ...

  7. perl6之'Hello World'

    安装完perl6之后,当然是要写一下Hello World了. 因为perl6的脚本一般都很短小,所以用不着很笨重的IDE之类的东西,我们用VIM,sublime text这种小型的编辑器 来开始pe ...

  8. 各种浏览器的agent信息(IE Chrome Safari Firefox)

    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/53 ...

  9. yii2安装与初始化-Yii2学习笔记(一)

    一.安装项目: 使用composer下载安装yii2 advanced安装包: composer create-project yiisoft/yii2-app-advanced advanced(自 ...

  10. django中使用json.dumps处理数据时,在前台遇到字符转义的问题

    django后台代码: import json ctx['dormitory_list'] = json.dumps([{", "is_checked": 1}, {&q ...