從鍵盤上輸入一個四位整數?
#include<stdio.h>main(){inta,b,c,d;scanf("%1d%1d%1d%1d",&a,&b,&c,&d)
;printf("%d%d%d%d",d,c,b,a);}或者:#include"stdio.h"voidmain(){inte,f=0;printf("請輸入一個四位整數:")
;scanf("%d",&e);while(e){f*=10;f+=e%10;e/=10;}printf("倒序后為:\n%d",f);}
從鍵盤上輸入一個四位整數?
#include<stdio.h>main(){inta,b,c,d;scanf("%1d%1d%1d%1d",&a,&b,&c,&d)
;printf("%d%d%d%d",d,c,b,a);}或者:#include"stdio.h"voidmain(){inte,f=0;printf("請輸入一個四位整數:")
;scanf("%d",&e);while(e){f*=10;f+=e%10;e/=10;}printf("倒序后為:\n%d",f);}