printf("请输入一个不多于五位的数字:\n");
int a = 0, b[5] = {0},count = 0;
scanf("%d",&a);
b[0] = a / 10000;
b[1] = a % 10000 / 1000;
b[2] = a % 1000 / 100;
b[3] = a % 100 / 10;
b[4] = a % 10;
for (int i = 0; i < 5; i++) {
if (b[i] != 0) {
count = 5 - i;
break;
}
}
printf("这是%d位数\n",count);
printf("逆序打印出为:\n");
for (int i = 4; i > 4 - count; i--) {
printf("%d",b[i]);
}
给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。
最新推荐文章于 2022-08-14 12:10:50 发布