阿拉伯数字转化成罗马字符
#include<iostream> #include<vector> #include<string> using namespace std; int main() { int num; cin>>num; string result; int a1[]={1000,900,500,400,100,90,50,40,10,9,5,4,1}; string a2[]={"M", "CM", "D", "CD", "C", "XC","L", "XL", "X", "IX", "V", "IV", "I"}; int i=0; while(num>0) { int count=num/a1[i]; while(count--) result+=a2[i]; num=num%a1[i]; i++; } cout<<result<<endl; }