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. JavaScript自我学习之解析与执行

    如果想要学好JavaScript那么我们首先必须要知道浏览器JavaScript引擎是如何解释执行JavaScript代码的,作为一名菜鸟,从自己学习JavaScript的过程来说,真心觉得不了解这些 ...

  2. varchar和Nvarchar的区别

    (1)varchar(N) 存储时 N的单位是字节  比如说varchar(2)  代表的是  该字段可以存储字节长度为2的数据 例子:可以添加  张 或者 ab  添加成功! 但添加的时候如果是: ...

  3. [置顶] highcharts封装使用总结

    Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是web应用程序添加有交互性的图表,并且免费提供给个人学习.个人网站和非商业用途使用.目前High ...

  4. debian修改系统语言为英文

    原文地址:http://www.chenyudong.com/archives/debian-change-locale-language.html 修改/etc/default/locale 文件里 ...

  5. Ecstore中如何调用发起Ajax请求

    Ecstore的JS框架使用了mootools,所以ajax调用也使用mootools中的Request组件. 语法: var myRequest = new Request([options]); ...

  6. Mysql 配置慢查询日志(SlowQueryLog)以及使用日志分析工具

    [ 查看系统关于慢查询的设置 ] mysql> show variables like '%slow%'; +---------------------------+-------------- ...

  7. linux软件安装(rpm,源码编译)

    1.rpm(redhat package manager)管理器主要目的在于解决软件的安装.卸载.升级.查询.验证等,例如升级过程中,保留软件的配置文件,安装过程中,检查软件依赖的库文件,以及卸载过程 ...

  8. dojo Tree 添加、删除节点

    var tree=this.tree; var store=tree.model.store; if(this.node){ console.log(this.node) var children=t ...

  9. Hdu1090

    #include <stdio.h> int main() { int i,T,a,b; scanf("%d",&T); ;i<T;i++){ scanf ...

  10. Eratosthenes筛选法计算质数

    <C和指针>第6章第4道编程题: 质数就是只能被1和本身整除的数.Eratosthenes筛选法是一种计算质数的有效方法.这个算法的第一步就是写下所有从2至某个上限之间的所有整数.在算法的 ...