将给定的数字转换成罗马数字。

所有返回的 罗马数字 都应该是大写形式。

这是一些对你有帮助的资源:

function convertToRoman(num) {
var nums =[,,,,,,,, , , , , , , ];
var romans = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","III","II", "I"];
var result ='';
nums.forEach((item,index)=>{
while(item<=num){
result += romans[index];
num -= nums[index];
}
})
return result;
}

Roman Numeral Converter的更多相关文章

  1. Roman Numeral Converter-freecodecamp算法题目

    Roman Numeral Converter 1.要求 将给定的数字转换成罗马数字 所有返回的罗马数字都应该是大写形式 2.思路 分别定义个位.十位.百位.千位的对应罗马数字的数组 用Math.fl ...

  2. FreeCodeCamp 中级算法(个人向)

    freecodecamp 中级算法地址戳这里 Sum All Numbers in a Range 我们会传递给你一个包含两个数字的数组.返回这两个数字和它们之间所有数字的和. function su ...

  3. [LeetCode] Roman to Integer 罗马数字转化成整数

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...

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

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  5. 【leetcode】Roman to Integer

    题目描述: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range fr ...

  6. [Leetcode] Roman to Integer

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...

  7. Integer to Roman -- LeetCode 012

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

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

  9. No.013:Roman to Integer

    问题: Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from ...

随机推荐

  1. Protobuf 数据类型

    .proto Type   Notes C++ Type Java Type double    double  double float    float  float int32 Uses var ...

  2. Tfs更新 TfsConfig

    Start TfsJobAgent TfsServiceControl unquiesce 更新serviving状态 TfsConfig diagnose /scope:updates TfsCon ...

  3. Java设计模式—单例模式

    Singleton是一种创建型模式,指某个类采用Singleton模式,则在这个类被创建后,只可能产生一个实例供外部访问,并且提供一个全局的访问点. 核心知识点如下: (1) 将采用单例设计模式的类的 ...

  4. 【android】使用RecyclerView和CardView,实现知乎日报精致布局

    完整代码,请参考我的博客园客户端,git地址:http://git.oschina.net/yso/CNBlogs 在写博客园客户端的时候,突然想到,弄个知乎日报风格的简单清爽多好!不需要那么多繁杂的 ...

  5. jstack用法

    第一步先找出Java进程ID,我部署在服务器上的Java应用名称为mrf-center: root@ubuntu:/# ps -ef | grep mrf-center | grep -v grep ...

  6. org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.my.service.ProductService] for bean with name 'productService' defi报错解决方法

    原 javaweb项目报错org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [XXX] ...

  7. Nginx配置性能优化(转)

    原文地址:http://blog.csdn.net/xifeijian/article/details/20956605 高层的配置 nginx.conf文件中,Nginx中有少数的几个高级配置在模块 ...

  8. 从页面到服务器,node实现文件下载

    起因: 新来了一个需求,让用户下载一个200m的zip文件,并且校验用户信息,难点:下载的文件是200M的. 现在维护的系统,以前的文件下载,走的是node的静态文件,用的express框架上自带的静 ...

  9. 20145328 《Java程序设计》实验一实验报告

    20145328 <Java程序设计>实验一实验报告 实验名称 Java开发环境的熟悉(Windows + IDEA) 实验内容 使用JDK编译.运行简单的Java程序: 使用IDEA 编 ...

  10. Java ArrayList在foreach中remove的问题分析

    目录 iterator itr.hasNext 和 itr.next 实现 倒数第二个元素的特殊 如何避坑 都说ArrayList在用foreach循环的时候,不能add元素,也不能remove元素, ...