#include <stdio.h>
struct RomanNum
{
int i;
int v;
int x;
int l;
int c;
};
struct RomanNum RN[101];
void adder(int index, int n)
{
if (n == 0) return;
if (n >= 40 && n <= 49)
RN[index].l ++, RN[index].x ++, n -= 40;
if (n >= 90 && n <= 99)
RN[index].c ++, RN[index].x ++, n -= 90;
if (n % 10 == 4)
RN[index].v ++, RN[index].i ++, n -= 4;
if (n % 10 == 9)
RN[index].x ++, RN[index].i ++, n -= 9;
if (n / 100 > 0)
RN[index].c += (n/100), n %= 100;
if (n / 50 > 0)
RN[index].l += (n/50), n %= 50;
if (n / 10 > 0)
RN[index].x += (n/10), n %= 10;
if (n / 5 > 0)
RN[index].v += (n/5), n %= 5;
if (n / 1 > 0)
RN[index].i += (n/1), n %= 1;
}
int main()
{
int i, n;
for (i = 0; i < 100; i ++)
{
adder(i, i + 1);
RN[i + 1].i = RN[i].i, RN[i + 1].v = RN[i].v, RN[i + 1].x = RN[i].x;
RN[i + 1].l = RN[i].l, RN[i + 1].c = RN[i].c;
}
while (1)
{
scanf("%d", &n);
if (n == 0) break;
n -= 1;
printf("%d: %d i, %d v, %d x, %d l, %d c\n", n+1, RN[n].i, RN[n].v, RN[n].x, RN[n].l, RN[n].c);
}
return 0;
}
回目錄
回首頁
沒有留言 :
張貼留言