Roman Numeral Converter
将给定的数字转换成罗马数字。
所有返回的 罗马数字 都应该是大写形式。
这是一些对你有帮助的资源:
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的更多相关文章
- Roman Numeral Converter-freecodecamp算法题目
Roman Numeral Converter 1.要求 将给定的数字转换成罗马数字 所有返回的罗马数字都应该是大写形式 2.思路 分别定义个位.十位.百位.千位的对应罗马数字的数组 用Math.fl ...
- FreeCodeCamp 中级算法(个人向)
freecodecamp 中级算法地址戳这里 Sum All Numbers in a Range 我们会传递给你一个包含两个数字的数组.返回这两个数字和它们之间所有数字的和. function su ...
- [LeetCode] Roman to Integer 罗马数字转化成整数
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...
- [LeetCode] Integer to Roman 整数转化成罗马数字
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- 【leetcode】Roman to Integer
题目描述: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range fr ...
- [Leetcode] Roman to Integer
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...
- 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 ...
- 【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 ...
- No.013:Roman to Integer
问题: Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from ...
随机推荐
- [笔记]Win10下编译Tesseract-OCR 4.0
Tesseract-OCR 4.0使用了LSTM网络,准确性相比3.x版本提升不少. 官网提供的安装包会提供一堆DLL,而我需要的是一个静态链接的exe文件,所以只能重新编译. 编译环境 Window ...
- JVM内存—堆(heap)栈(stack)方法区(method) (转)
JAVA的JVM的内存可分为3个区:堆(heap).栈(stack)和方法区(method) 堆区:1.存储的全部是对象,每个对象都包含一个与之对应的class的信息.(class的目的是得到操作指令 ...
- XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem J. Terminal
题目:Problem J. TerminalInput file: standard inputOutput file: standard inputTime limit: 2 secondsMemo ...
- Hadoop2.0环境搭建
需准备的前提条件: 1. 安装JDK(自行安装) 2. 关闭防火墙(centos): systemctl stop firewalld.service systemctl disable firewa ...
- js中获取时间戳
function conver(){ var date = new Date(); var year = date.getFullYear() var month=date.getMonth()+1; ...
- 为什么gitHub提交记录显示作者名称是unknow?
unknow,为什么? gitHub上提交记录显示作者名称是unknow,刚开始没怎么管,后面遇到问题看提交记录时发现有两个unknow(一定有一个人遇到和我一样的问题了,哈哈..),于是解决一下吧. ...
- Python面试题之Python生成器
首先说明一下生成器也是迭代器,也有迭代器的那些优点. 那为什么要生成器呢?因为到目前为止都 不是你写的迭代器,都是别人定义好的.那如何自己去造一个迭代器呢?下面的内容就会给你答案. 想要自己造一个迭代 ...
- Python3.x:如何识别图片上的文字
Python3.x:如何识别图片上的文字 安装pytesseract库,必须先安装其依赖的PIL及tesseract-ocr,其中PIL为图像处理库,而后面的tesseract-ocr则为google ...
- mybatis中使用mysql的模糊查询字符串拼接(like)
方法一: <!-- 根据hid,hanme,grade,模糊查询医院信息--> 方法一: List<Hospital> getHospitalLike(@Param(" ...
- hdu5616 暴力枚举
2017-08-25 20:08:54 writer:pprp 题目简述: • HDU 5616• n个砝码,可以放在天平左右两侧或不放• m次询问,每次询问是否可以测出给定重量• 1 ≤ n ≤ 2 ...