这是一个将罗马数字值打印到a的程序
一百个一切正常,除了i==88
时,在此行选项卡上缩进一个额外的集停止。
我有点理解为什么那是8个字符。
我该如何解决这个问题?
谢谢。
int main() {
unsigned int i, tensDigit, singleUnit;
printf( "Roman Numeral\t\t\t\tDecimal\n");
for ( i = 1; i <= 100; i++ ) {
tensDigit = i / 10;
singleUnit = i % 10;
switch ( tensDigit ) {
case 0:
break;
case 1:
printf("X");
break;
case 2:
printf("XX");
break;
case 3:
printf("XXX");
break;
case 4:
printf("XL");
break;
case 5:
printf("L");
break;
case 6:
printf("LX");
break;
case 7:
printf("LXX");
break;
case 8:
printf("LXXX");
break;
case 9:
printf("XC");
break;
case 10:
printf("C");
break;
default:
break;
}
switch ( singleUnit ) {
case 0:
printf("\t\t\t\t%d\n", i);
break;
case 1:
printf("I\t\t\t\t%d\n", i);
break;
case 2:
printf("II\t\t\t\t%d\n", i);
break;
case 3:
printf("III\t\t\t\t%d\n", i);
break;
case 4:
printf("IV\t\t\t\t%d\n", i);
break;
case 5:
printf("V\t\t\t\t%d\n", i);
break;
case 6:
printf("VI\t\t\t\t%d\n", i);
break;
case 7:
printf("VII\t\t\t\t%d\n", i);
break;
case 8:
printf("VIII\t\t\t\t%d\n", i);
break;
case 9:
printf("IX\t\t\t\t%d\n", i);
break;
}
}
return 0; }