LeetCode Integer to Roman数字转成罗马数字
来源:互联网 发布:数据产品经理面试题目 编辑:程序博客网 时间:2024/06/05 06:04
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
把数字转换成为罗马数字,一般我们都不太熟悉罗马数字,所以只能Wiki一下了:http://en.wikipedia.org/wiki/Roman_numerals
程序是入门级的了:
class Solution {public:string intToRoman(int num) {int digits[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};string symbols[] = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};string result;int i = 0;while (num > 0){int times = num / digits[i];num -= times*digits[i];for (int j = 0; j < times; j++){result += symbols[i];}++i;}return result;}};
- LeetCode Integer to Roman数字转成罗马数字
- [LeetCode-13] Roman to Integer(罗马数字转成阿拉伯数字)
- Leetcode 13 Roman to Integer 罗马数字转成整数
- LeetCode-13-Roman to Integer(罗马数字转换为整型数字)
- 罗马数字变数字(Roman to Integer)
- Integer to Roman (罗马数字转换) 【leetcode】
- Roman to Integer 罗马数字转阿拉伯数字@LeetCode
- Integer to Roman 阿拉伯数字转罗马数字@LeetCode
- LeetCode Roman to Integer 罗马数字转阿拉伯数字
- [LeetCode]-Integer to Roman 阿拉伯数字转罗马数字
- [LeetCode]Integer to Roman整数转罗马数字
- LeetCode Roman to Integer(罗马数字转换)
- (LeetCode) Roman to Integer --- 罗马数字转整数
- 【LeetCode-面试算法经典-Java实现】【013-Roman to Integer (罗马数字转成整数)】
- 13.Roman to Integer (罗马数字转成整数)
- leetcode解题之 12&13. Integer to Roman Java版(罗马数字和数字的转换)
- [LeetCoce 13] Roman to Integer 罗马数字转化为数字
- 12:Integer to Roman(数字转为罗马数字)
- File输入输出流综合
- Libevhtp
- 利用内存数据库和布隆过滤器写的网络爬虫
- C++对于bit的操作 bit直接赋值 及其他技巧(未完)
- C语言中static的作用
- LeetCode Integer to Roman数字转成罗马数字
- Struts介绍及学习视频
- 混合背包
- 【转载】ubuntu server 命令行下更换软件源
- 遇到的问题-----------perl脚本用handlersocket把数据插入mysql执行时报错lock_tables
- Android下的两个文件系统:proc和sys(二)
- 阅读大型代码库的方法
- Kernel中Module调用编译问题
- [转]Linux tcpdump命令详解