LeetCode——整数转罗马数字

题目链接:https://leetcode-cn.com/problems/integer-to-roman/

public static String intToRoman(int num) {
        int[] value = { 1000, 900, 500, 400, 100, 90, 50,40, 10, 9, 5, 4, 1};
        String[] symbol = { "M", "CM", "D", "CD", "C", "XC", "L","XL", "X", "IX", "V", "IV", "I"};
    	StringBuffer sb = new StringBuffer();
    	while (num > 0){
        for (int i = 0; i < value.length; i++) {
            while (num >= value[i]){
                sb.append(symbol[i]);
                num-=value[i];
            }
        }
    }
    return sb.toString();
    }