char s[100];
char* intToRoman(int num) {
char rs[] = "MDCLXVI";
int ts[] = { 1000,500,100,50,10,5,1 };
int cnt = 0;
while(num){
int i = 0;
while(ts[i] > num) i++;
if(i && num >= 4*ts[i]){
s[cnt++] = rs[i];
s[cnt++] = rs[i-1];
num -= 4*ts[i];
}
else if(i && i+1 < 7 && ts[i] == 5*ts[i+1] && num >= ts[i]+ts[i+1]*4){
s[cnt++] = rs[i+1];
s[cnt++] = rs[i-1];
num -= ts[i] + ts[i+1]*4;
}
else{
int n = num / ts[i];
num -= n*ts[i];
while(n--) s[cnt++] = rs[i];
}
}
s[cnt] = 0;
return s;
}