#include <iostream>
#include <string>
#include <cstring>
//std::string strroman[]={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
class Solution {
public:
std::string intToRoman(int num) {
int i;
std::string roman;
int value[]={1000,900,500,400,100,90,50,40,10,9,5,4,1};
std::string Roman[ ]={"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"};
// char roman[20];
for ( i = 0; num > 0; ++i)
{
int count;
count = num/value[i];
num %= value[i];
for (; count > 0; --count)
{ roman += Roman[i];}
}
return roman;
}
};
int main()
{
using namespace std;
int Integer;
//string roman;
cout << "Integer: ";
Solution integer_to_roman;
cin >> Integer ;
cout<< "Roman:"<<integer_to_roman.intToRoman(Integer)<<endl;
system("pause");
return 0;
}
07-13
07-13
07-13
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交