#include<stdio.h> int main() { int a,b,c,number; scanf("%d",&number); printf("百位:%d\n",a=number/100); printf("十位:%d\n",b=(number-100*a)/10); printf("个位:%d\n",c=number-100*a-10*b); return 0; }
以此类推,若该数不止三位,也可将其各位输出。
时间: 2024-11-03 03:28:25
#include<stdio.h> int main() { int a,b,c,number; scanf("%d",&number); printf("百位:%d\n",a=number/100); printf("十位:%d\n",b=(number-100*a)/10); printf("个位:%d\n",c=number-100*a-10*b); return 0; }
以此类推,若该数不止三位,也可将其各位输出。