模拟模拟模拟

class Solution {
public:
string intToRoman(int num) {
int Cnt = 0;
string ans = "";
while (num) {
++Cnt;
int temp=num % 10;
num/=10;
string k = "";
if (temp > 5) {
if (temp == 9){
if (Cnt == 1)k = "IX";
else if (Cnt == 2)k = "XC";
else k = "CM";
}
else {
if(Cnt==1)k = "V";
else if (Cnt == 2)k = "L";
else k = "D";
while (temp - 5) {
--temp;
if(Cnt==1)k += "I";
else if (Cnt == 2)k += "X";
else k += "C";
}
}
}
else if (temp < 5) {
if (temp == 4){
if(Cnt==1)k = "IV";
else if (Cnt == 2)k = "XL";
else k = "CD";
}
else {
while (temp) {
--temp;
if(Cnt==1)k += "I";
else if (Cnt == 2)k += "X";
else if (Cnt == 3)k += "C";
else k += "M";
}
}
}
else {
if(Cnt==1)k = "V";
else if (Cnt == 2)k = "L";
else k = "D";
}
ans = k + ans;
}
return ans;
}
};