Given an integer, convert it to a roman numeral.

Input is guaranteed to be within the range from 1 to 3999.

int key[]={, , , , ,, , , , , , , };
string romans[]={"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}; class Solution {
public:
string intToRoman(int num) {
for(int i = ; i < ; ++ i){
if(key[i]<= num) return romans[i]+intToRoman(num-key[i]);
}
return "";
}
};

Leetcode Integer to Roman的更多相关文章

  1. LeetCode: Integer to Roman 解题报告

    Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...

  2. [LeetCode] Integer to Roman 整数转化成罗马数字

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  3. LeetCode——Integer to Roman

    Description: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the r ...

  4. leetcode Integer to Roman python

    class Solution(object): def intToRoman(self, num): """ :type num: int :rtype: str &qu ...

  5. [LeetCode][Python]Integer to Roman

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/integer ...

  6. Integer to Roman - LeetCode

    目录 题目链接 注意点 解法 小结 题目链接 Integer to Roman - LeetCode 注意点 考虑输入为0的情况 解法 解法一:从大到小考虑1000,900,500,400,100,9 ...

  7. LeetCode OJ:Integer to Roman(转换整数到罗马字符)

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  8. LeetCode:12. Roman to Integer (Easy)

    1. 原题链接 https://leetcode.com/problems/roman-to-integer/description/ 2. 题目要求 (1)将罗马数字转换成整数:(2)范围1-399 ...

  9. leetCode练题——12. Integer to Roman

    1.题目 12. Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C,  ...

随机推荐

  1. php获取一维,二维数组长度的方法(有实例)

    在php中获取数组长度方法很简单,php为我们提供了两个函数可以计算一维数组长度,如count,sizeof都可以直接统计数组长度哦,下面我们来看几个实例吧.php如何获取数组的长度,使用php函数c ...

  2. JAVA基础学习之IP简述使用、反射、正则表达式操作、网络爬虫、可变参数、了解和入门注解的应用、使用Eclipse的Debug功能(7)

    1.IP简述使用//获取本地主机ip地址对象.InetAddress ip = InetAddress.getLocalHost();//获取其他主机的ip地址对象.ip = InetAddress. ...

  3. Delphi中uses在interfeace和implementation中的区别

    use单元引入分为在interface中引入,如 interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...

  4. 网站性能测试工具--MS Web Application Stress Tool

    MS Web Applicaion Stress Tool 是一款网页测试的性能工具,具体的使用可以参考下面这篇博客文章 http://cuisuqiang.iteye.com/blog/193640 ...

  5. android 入门-Activity及 字体

    private Button sButton; private TextView mTextView; private Button fButton; ,,,,}; @Override protect ...

  6. [v9] 列表页 调用 正文内容 或 自定义 字段(moreinfo的调用方法)

    "才能使用的字段) id content readpoint groupids_view paginationtype maxcharperpage template paytype all ...

  7. MongoDB学习(1)—在Windows系统中安装MongoDB

    概述 本文主要介绍在Windows系统安装MongoDB的方法. MongoDB官方网址:http://www.mongodb.org/,最新版本为2.6.7. 注意: 从2.2版本开始,MongoD ...

  8. zoj 3471(状态压缩)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4257 dp[state]表示当前状态为state时的所能获得的最大值 ...

  9. 初探Docker

    本文旨在让大家了解什么是Docker,并带领大家体验Docker使用的整个流程. 开启Docker学习之旅前,我们简单描述几个场景,应该很多人都有碰到过: 小凹同学开发了一个web应用,服务器环境是: ...

  10. flex_宽度补全

    宽度40px,另一个的补全宽度: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...