本文主要是介绍LeetCode 12. Integer to Roman -- 整数转换成罗马数字,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
给定一个整数num,( 1<=num<=3999),将整数转换成罗马数字。如1,2,3,4,5对应的罗马数字分别位I,II,III,IV,V等。格式:第一行输入一个整数,接下来输出对应的罗马数字。提示:罗马数字的常识见此链接http://baike.baidu.com/link?url=injU8M4bAoc2zRZQ1GtgrfvuzCJO9PLnq6fpQGJLenakbzo-rS8p-qsYHR_81-aN样例1输入:123
输出:CXXIII
package com.main;public class Main {public String intToRoman(int num) {String digit[] = {"", "I", "II", "III", "IV", "V", "VI", "VII","VIII", "IX"};String ten[] = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX","XC"};String hundred[] = {"", "C", "CC", "CCC"
这篇关于LeetCode 12. Integer to Roman -- 整数转换成罗马数字的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!