Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999与罗马字符转数字类似,注意按级处理。string intToRoman(int num){...
分类:
其他好文 时间:
2015-04-22 23:54:51
阅读次数:
167
题目:
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
翻译:把罗马转为数字
思路:如果是单纯的一个罗马字母比较好处理,但是对于4,9这样的,应该看它下一个字符代表的数字是不是比他大,要是大的话减去当前的字符...
分类:
其他好文 时间:
2015-04-22 15:25:50
阅读次数:
169
题目:
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
翻译:
给一个整数,把他转换为罗马数字输出。
这道题是简单的字符转换的问题。只要了解罗马数字代表的含义即可。
罗马数字里面只有 1,5,10...
分类:
其他好文 时间:
2015-04-22 13:53:46
阅读次数:
112
不知道现在的自己属不属于IT界一员,或者说是半个IT界一员,从建筑行业转向IT行业,也是下了很大决心,俗话说“条条大路通罗马”,的确,每个人选择的路也许一样,也许不一样,既然选择了,就要好好走下去,为自己加油! 接触前端也有一个星期了,不过确切的说还算不上入门,现在学的还是最基础的C语言,不过就这....
分类:
Web程序 时间:
2015-04-20 00:26:05
阅读次数:
136
/* 题意:把阿拉伯数字转换成罗马数字 解法:直接暴力枚举了。*/class Solution {public: int power(int k){ int res = 1; for(int i = 0 ; i < k ; i++) res*=10; ...
分类:
其他好文 时间:
2015-04-18 21:50:49
阅读次数:
134
/* 题意:罗马数字转换成阿拉伯数字 解法:用map映射一下,判断当前字母是否比下一个小,是的话ans加上下一字母的值-当前字母的值, 否则的话直接加上当前字母的值。*/class Solution {public: int romanToInt(string s) { ...
分类:
其他好文 时间:
2015-04-18 21:50:36
阅读次数:
156
Roman to Integer
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
解题思路:
罗马数字转化成数字。一种方法是映射法,每一位(阿拉伯数字)的字符到阿拉伯数字的映射。如下所示:
class Solu...
分类:
其他好文 时间:
2015-04-18 20:40:01
阅读次数:
167
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.首先,学习一下罗马数字,参考罗马数字罗马数字是最古老的数字表示方式,比阿拉伯数组早200...
分类:
其他好文 时间:
2015-04-18 20:21:32
阅读次数:
116
Integer to Roman
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
解题思路:
数字转罗马字符。并不是非常复杂,罗马字符的表示如维基百科所述http://zh.wikipedia.org/wiki/...
分类:
其他好文 时间:
2015-04-18 19:15:08
阅读次数:
135