12. Integer to Roman

Posted 鸵鸟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了12. Integer to Roman相关的知识,希望对你有一定的参考价值。

class Solution {
    public String intToRoman(int num) {
        String[][] r=new String[][]{{"","M","MM","MMM"},
                        {"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"},
                        {"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"},
                        {"","I","II","III","IV","V","VI","VII","VIII","IX"}};
        return r[0][num/1000]+r[1][num%1000/100]+r[2][num%100/10]+r[3][num%10];
    }
}

 

以上是关于12. Integer to Roman的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode Medium:12. Integer to Roman

12. Integer to Roman

12 Integer to Roman

12. Integer to Roman

12. Integer to Roman

12. Integer to Roman