Note: People using GCC need to compile with -lm since we are using math.h
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(int argc, char *argv[])
{
char t[] = {'I','X','C','M','V','L','D'};
char r[37] = {0};
int pos = 0;
if(argc == 2){
argc = 0;
while(argv[1][argc++] != '\0')
{
while(((argv[1][argc-1])--) - 48 > 0)
{
if(argv[1][argc-1] - 48 >= 4 && strlen(argv[1])-argc != 3){
r[pos++] = t[strlen(argv[1])-argc+4];
argv[1][argc-1]-=4;
}else
r[pos++] = t[strlen(argv[1])-argc];
}
}
printf("%s\n",r);
}
return 0;
}
Edited by TkTech, 21 September 2009 - 02:41 AM.
Typo oO


Sign In
Create Account

Back to top










