1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| #include<stdio.h> int main(){ int a; scanf("%d",&a); if(a>=10000){ int b,c,d,e,f; b=a/10000; c=(a-b*10000)/1000; d=(a-b*10000-c*1000)/100; e=(a-b*10000-c*1000-d*100)/10; f=(a-b*10000-c*1000-d*100-e*10)/1; printf("该数为五位数"); printf("万位%d千位%d百位%d十位%d个位%d",b,c,d,e,f); printf("%d%d%d%d%d",f,e,d,c,b); }else if(a>=1000){ int c,d,e,f; c=a/1000; d=(a-c*1000)/100; e=(a-c*1000-d*100)/10; f=(a-c*1000-d*100-e*10)/1; printf("该数为四位数"); printf("千位%d百位%d十位%d个位%d",c,d,e,f); printf("%d%d%d%d",f,e,d,c); }else if(a>=100){ int d,e,f; d=a/100; e=(a-d*100)/10; f=(a-d*100-e*10)/1; printf("该数为三位数"); printf("百位%d十位%d个位%d",d,e,f); printf("%d%d%d",f,e,d); }else if(a>=10){ int e,f; e=a/10; f=(a-e*10)/1; printf("该数为二位数"); printf("十位%d个位%d",e,f); printf("%d%d",f,e); }else if(a>=1){ int f; f=a/1; printf("该数为一位数"); printf("个位%d",f); printf("%d",f); } }
|