整数转换成罗马数字

时间限制: 1000ms 内存限制: 65536K

题目描述

给定一个整数 numnum,将整数转换成罗马数字。

如 1,2,3,4,51,2,3,4,5 对应的罗马数字分别为IIIIIIIVV等,更详细的说明见此 链接

输入格式

第一行输入一个整数 num(1 \leq num \leq 3999)num(1num3999)

输出格式

输出 numnum 对应的罗马数字。

样例输入

123

样例输出

CXXIII
#include<stdio.h>
int main()
{
    int num;
    char *units_digit[10]={"","I","II","III","IV","V","VI","VII","VIII","IX"};
    char *tens_digit[10]={"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
    char *hundreds_digit[10]={"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
    char *thousand_digit[4]={"","M","MM","MMM"};
    scanf("%d",&num);
    printf("%s",thousand_digit[num/1000]);
    printf("%s",hundreds_digit[num%1000/100]);
    printf("%s",tens_digit[num%100/10]);
    printf("%s",units_digit[num%10]);
    return 0;
}