[LeetCode]13. Roman to Integer
来源:互联网 发布:哪个软件可以化妆 编辑:程序博客网 时间:2024/06/13 13:24
题目:Given a roman numeral, convert it to aninteger.
Input is guaranteed to be within the rangefrom 1 to 3999.
代码如下:
//罗马数字转为int型整数int RomanToint(string &s ) {unordered_map<char, int> T = { { 'I', 1 },{ 'V', 5 },{ 'X', 10 },{ 'L', 50 },{ 'C', 100 },{ 'D', 500 },{ 'M', 1000 } };int sum = T[s.back()];for (int i = s.length() - 2; i >= 0; --i)if (T[s[i]] < T[s[i + 1]])sum -= T[s[i]];elsesum += T[s[i]];return sum;}
1 0
- LeetCode 13. Roman to Integer
- [LeetCode]13.Roman to Integer
- LeetCode --- 13. Roman to Integer
- [Leetcode] 13. Roman to Integer
- [leetcode] 13.Roman to Integer
- leetcode 13. Roman to Integer
- leetcode 13. Roman to Integer
- LeetCode 13. Roman to Integer
- [LeetCode]13. Roman to Integer
- Leetcode 13. Roman to Integer
- leetcode 13. Roman to Integer
- leetcode 13. Roman to Integer
- LeetCode *** 13. Roman to Integer
- LeetCode 13. Roman to Integer
- LeetCode 13. Roman to Integer
- 【LeetCode】13. Roman to Integer
- Leetcode 13. Roman to Integer
- LeetCode 13. Roman to Integer
- tensorflow实现P@1和MRR
- 关于hexo搭建博客后的一些基础配置
- Jsp状态管理
- 第七届Java软件开发C组
- java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because
- [LeetCode]13. Roman to Integer
- Elasticsearch垃圾回收日志
- 第一篇文章·前言
- Makefile编译时怎么打印出变量值
- git clone remote fetch pull push等操作
- HDU 1257 最少拦截系统
- JS实现进制转换
- 前端CSS基础之 clear:both
- Hadoop之HDFS的配置---secondarynode版本