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

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

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

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. SQL Server自定义字符串分割函数——Split

    我相信大部分人都碰到过,处理数据的时候,字段的值是以 ',' (逗号)分隔的形式,所以我也不能避免. 然后我才知道,sql 是没有类似于 C# 和 Javascript 这种分割字符串的方法.( Sp ...

  2. [笔记] Ubuntu 18.04安装cuda 10及cudnn 7流程

    安装环境 OS:Ubuntu 18.04 64 bit 显卡:NVidia GTX 1080 任务:安装 CUDA 10及cuDNN 7 工具下载 NVidia官网下载下列文件: CUDA 10:cu ...

  3. ECMAScript与JavaScript

    ECMAScript发展史: 1997 1998.6 1999.12 2008.7 2009.12 2015.61996年11月 javaScript创造者Netscape公司将javaScript提 ...

  4. 懒加载 js----例子------图片

    转载自:https://www.jianshu.com/p/9b30b03f56c2 懒加载工具类 <script type="text/javascript"> // ...

  5. MySQL 温故知心(一)

    1.创建表 SET NAMES utf8; ; -- ---------------------------- -- Table structure for `employee_tbl` -- --- ...

  6. cocos2d-x项目中如何避免增加一个cpp就必须在工程android.mk文件去添加引用

    LOCAL_SRC_FILES := hellocpp/main.cpp \       ../../Classes/AppDelegate.cpp \ ../../Classes/HelloWorl ...

  7. 20145329《Java程序设计》第八周学习总结

    教材学习内容总结 日志 1.java.util.logging包提供了日志功能相关类与接口. 2.使用日志的起点是Logger类,Longer类的构造函数标示为protected,不同包的类药取得Lo ...

  8. openwrt中的append-ubi定义在哪里

    include/image-commands.mk 定义如下: define Build/append-ubi sh $(TOPDIR)/scripts/ubinize-image.sh \ $(if ...

  9. git 总结命令

    git 命令 创建git版本库:git init 查看状态:git status 把文件添加到暂存区:git add 把文件提交到版本库:git commit  -m "提交说明" ...

  10. python 编程测试练习2

    1.将A.txt(多行)文件的内容读取出来写入到B.txt中 2.总结 一.python中对文件.文件夹操作时经常用到的os模块和shutil模块常用方法. 1.得到当前工作目录,即当前Python脚 ...