#include <stdio.h>
#include <string>
#include <stdlib.h>
int main()
{
int num[7] = { 1,5,10,50,100,500,1000 };
char str[7] = { 'I','V','X','L','C','D','M' };
char rom[10][5] = { "\0","I","II","III","IV","V","VI","VII","VIII","IX" };
for (int j = 0; j <= 100; j++)
{
int i = j;
while (i)
{
if (i < 10) //10,40,50,90,100都是特殊处理的分界线
{
puts(rom[i]);
i = 0;
}
if (i == 100)
{
puts("C");
i = 0;
}
if (i >= 90)
{
putchar('X');
putchar('C');
i -= 90;
}
if (i >= 50)
{
putchar(str[3]);
i -= 50;
}
if (i >= 40)
{
putchar('X');
putchar('L');
i -= 40;
}
while (i>=10)
{
putchar('X');
i -= 10;
}
}
printf("\n");
}
system("pause");
return 0;
}
打印罗马数字
最新推荐文章于 2022-01-16 23:09:47 发布