1、求出它是幾位數(shù)
2、分別輸出每一位數(shù)字
3、按逆序輸出各位數(shù)字,例如原數(shù)為321,應輸出123.
3 回答
已采納

望遠
TA貢獻1017條經(jīng)驗 獲得超1032個贊
#include<stdio.h> void?main() { int?n,m,count=0; scanf("%d",&n); if(n>=100000) return; m=n; printf("逆序輸出:"); while(n>0) { printf("%d",n%10); n=n/10; count++; } printf("%d是%d位數(shù)\n",m,count); }

紫晴20
TA貢獻9條經(jīng)驗 獲得超5個贊
#include<stdio.h>
void main()
{
? ?int i = 0, x, y[20];
? ?printf("輸入數(shù)字:n = "); ? scanf("%d", &x);
? ?while (x) {
? ? ?y[i] = x % 10;
????x /= 10;
? ? ?i++;
}
? ?printf("\n這個數(shù)字共有 %d 位數(shù)。\n", i);
? ?for (x = i; x > 0; x--) ?printf("%d, ", y[x - 1]); ?printf("\n");
? ?for (x = 0; x < i; x++) ?printf("%d, ", y[x]); ?printf("\n");
}
- 3 回答
- 0 關注
- 1511 瀏覽
添加回答
舉報
0/150
提交
取消