本文主要是介绍【LeetCode算法练习(C++)】Integer to Roman,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目:
Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
ps:
I = 1;
V = 5;
X = 10;
L = 50;
C = 100;
D = 500;
M = 1000;
链接:Integer to Roman
解法:贪心,每次选择能表示的最大值
class Solution {
public: string intToRoman(int num) { string ans; string symbol[] = {"M", "CM", "D"
这篇关于【LeetCode算法练习(C++)】Integer to Roman的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!