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 ...
随机推荐
- Ubuntu16.04 Docker 安装
前提条件 Docker 要求 Ubuntu 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的 Ubuntu 版本是否支持 Docker. 通过 uname -r 命令查看你当前的内核版本 ...
- Mysql中间件_haproxy在启动过程中报错_Starting proxy : cannot bind socket
在搭建好haproxy准备启动中,使用service命令的方式启动没有报任何错误,但是监听服务发现并没有想象的顺利,搜索各种帖子,参考对照发现,发现一条新的命令,^_^,试着用下面命令启动,惊喜~发现 ...
- Cisco 交换Vlan配置
添加Vlan命令 #添加vlan100 config)#vlan 100 #重命名vlan100 config-vlan)#name vlan100 #返回上一层 config-vlan)#exit ...
- web.xml listener配置
listener简介: <listener>能为web应用创建监视器,监听上下文的各种事件,如:application和session事件,这些监视器都是按相同的方式定义,它的功能取决于各 ...
- 当新手使用JS库遇到问题怎么办
见标题,知其意.在做网站时候,其实我们会用很多JS库,网络上流行的和公司自己封装的,这些东西都很好用,但是或多或少的有些bug或者有一些缺陷,即使真的很完善,但也可能达不到自己特定的一些需求.所以遇到 ...
- IPTABLES拒绝某个IP某项服务,并记录到日志(rhel7实例)
#iptables -I INPUT -p icmp -s 192.168.0.1 -j DROP \\在INPUT链中插入:如果检测到从192.168.0.1发过来的 ...
- Spring中RestTemplate进行Http调用
Spring中的RestTemplate类源自spring-web,http调用中设置超时时间.设置连接池管理等非常重要,保证了系统的可用性,避免了长时间连接不上或者等待数据返回,拖垮系统. 现贴出工 ...
- 【边框回归】边框回归(Bounding Box Regression)详解(转)
转自:打开链接 Bounding-Box regression 最近一直看检测有关的Paper, 从rcnn, fast rcnn, faster rcnn, yolo, r-fcn, ssd,到今年 ...
- LIS学习笔记(两种算法)O(n^2) 和 O(nlogn)
2017-09-02 10:34:21 writer:pprp 最长上升子序列,具体分析看代码:O(n^2)的做法,dp的思想 分析:每次读一个进行扫描,如果当前读入的这个要比之前的大, 说明有可能加 ...
- Hadoop 常用指令
1. 察看hdfs文件系统运行情况 bin/hdfs dfsadmin -report 2. 为了方便执行 HDFS 的操作指令,我们可以将需要的 Hadoop 路径写入环境变量中,便于直接执行命令. ...