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 ...
随机推荐
- javascript 对象 原型 prototype
- Log4net 自定义字段 写入Oracle 使用ODP.NET Managed驱动
一.环境说明: 开发工具:vs2010 ,数据库:oracle 11g ,版本:log4net的目前最新版本1.2.13.0 : Oracle.ManagedDataAccess.dll ...
- iClap助力移动互联网企业实现规范化管理
移动互联网的迅速崛起,智能移动客户端深刻而全面地影响着人类生活与工作习惯.而企业办公已从原始的纸张办公,到固定PC办公,跨入到一个应用范围更广.效率更高的移动办公时代.由静生动,让企业办公更加人性化和 ...
- 2017 Multi-University Training Contest - Team 4 hdu6069 Counting Divisors
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6069 题目: Counting Divisors Time Limit: 10000/5000 ...
- How can For each...
Answer: I understand the IEnumerator/IEnumerable methods and properties and also how they are inte ...
- TOSCA自动化测试工具--TestSuite Components
TestSuite Components 分了6块
- JMS--消息头
一个消息对象分为三部分:消息头(Headers),属性(Properties)和消息体(Payload).对于StreamMessage和MapMessage,消息本身就有特定的结构,而对于TextM ...
- Linux各目录缩写含义
Unix已经有35年历史了.许多人认为它开始于中世纪,这个中世纪是相对于计算机技术的产生和发展来说的.在过去的时间里,Unix和它的子分支Linux收集有许多的历史和一些完全古老的语言.在这篇技巧文章 ...
- 基于tomcat集群做session共享
前端代理服务器nginx:192.168.223.136 tomcat服务器:采用的一台多实例192.168.223.146:8081,192.168.223.146:8082(如何构建多实例tomc ...
- pxe基于虚拟机的自启动
环境系统:centos6.4 min版 虚拟机实现:提供的服务器ip为192.168.0.105,桥接 安装dhcp服务: yum -y install dhcp 配置dhcp服务,使能够成功启动: ...