[Leetcode]012. Integer to Roman
public class Solution {
public String intToRoman(int num) {
String M[] = {"", "M", "MM", "MMM"};
String C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
String X[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
String I[] = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};
return M[ num/1000 ] +
C[ (num%1000) / 100] +
X[(num%100)/10] +
I[num%10];
}
}
[Leetcode]012. Integer to Roman的更多相关文章
- 【JAVA、C++】LeetCode 012 Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- [LeetCode][Python]Integer to Roman
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/integer ...
- 【leetcode】Integer to Roman
Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be within t ...
- 【leetcode】Integer to Roman & Roman to Integer(easy)
Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within t ...
- No.012 Integer to Roman
12. Integer to Roman Total Accepted: 71315 Total Submissions: 176625 Difficulty: Medium Given an int ...
- Leetcode 12——Integer to Roman
12.Integer to Roman Given an integer, convert it to a roman numeral. Input is guaranteed to be withi ...
- LeetCode--No.012 Integer to Roman
12. Integer to Roman Total Accepted: 71315 Total Submissions: 176625 Difficulty: Medium Given an int ...
- Leetcode 12. Integer to Roman(打表,水)
12. Integer to Roman Medium Roman numerals are represented by seven different symbols: I, V, X, L, C ...
- 【LeetCode】012. Integer to Roman
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
随机推荐
- Linux下几种RTP协议实现的比较和JRTPLIB编程讲解
流媒体指的是在网络中使用流技术传输的连续时基媒体,其特点是在播放前不需要下载整个文件,而是采用边下载边播放的方式,它是视频会议. IP电话等应用场合的技术基础.RTP是进行实时流媒体传输的标准协议和关 ...
- 白话算法(6) 散列表(Hash Table) 从理论到实用(下)
[澈丹,我想要个钻戒.][小北,等等吧,等我再修行两年,你把我烧了,舍利子比钻戒值钱.] ——自扯自蛋 无论开发一个程序还是谈一场恋爱,都差不多要经历这么4个阶段: 1)从零开始.没有束缚的轻松感.似 ...
- CentOS 6.X 安装 EPEL 源
CentOS 6.X 自带的软件源可选的并不多,有时候要找到一个偏门一些的软件,用命令一搜怎么都没有源,考虑到使用软件源配合 yum 命令安装可以自动安装依赖,所以加一个新的软件源迫在眉睫. 考虑到同 ...
- Poj1298_The Hardest Problem Ever(水题)
一.Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar eve ...
- AD9 如何画4层pcb板
新建的PCB文件默认的是2层板,教你怎么设置4层甚至更多层板. 在工具栏点击Design-->Layer Stack Manager.进入之后显示的是两层板,添加为4层板,一般是先点top la ...
- 加固mysql服务器
实验环境:CentOS7 [root@~ localhost]#yum -y install mariadb-server [root@~ localhost]#mysql_secure_instal ...
- maven可用镜像
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...
- 创建Ajax
Ajax的全称是Asynchronous javascript and XML = 异步传输 + JS + XML 不需要刷新页面就可以获取新的数据 创建步骤: (1)创建XML对象也就 ...
- 10.Ubuntu16搭建蜜罐Cowrie
一直都想尝试搭建一个蜜罐,因为蜜罐是一款可以对ssh,telnet,http等等协议攻击进行记录,对于输入命令和上传文件均有记录的一款软件. 记录可以设置在日志文件中或者通过配置数据库,导入数据库中方 ...
- Head First HTML与CSS(第2版) 中文pdf扫描版
是不是已经厌倦了那些深奥的HTML书?你可能在抱怨,只有成为专家之后才能读懂那些书.那么,找一本新修订的<Head First HTML与CSS(第2版)>吧,来真正学习HTML.你可能希 ...