逆向输出
#include<stdio.h>void main()
{
long int sum;
int w,q,b,s,g,ws;
printf("shu ru yi ge bu da yu wu wei de shu:");
scanf("%ld\n",&sum);
while(sum>9999)
{
printf("shu ru cuo wu:");
scanf("%ld\n",&sum);
}
if(sum>9999) ws=5;
else if(sum>999) ws=4;
else if(sum>99) ws=3;
else if(sum>9) ws=2;
else ws=1;
w=(int)sum/10000;
q=(int)(sum-w*10000)/1000;
b=(int)(sum-w*10000-q*1000)/100;
s=(int)(sum-w*10000-q*1000-b*100)/10;
g=(int)(sum-w*10000-q*1000-b*100-s*10);
switch(ws)
{
case 5: printf("sun xu shu chu:");
printf("%d%d%d%d%d",w,q,b,s,g);
printf("\ni xu shu chu:");
printf("%d%d%d%d%d\n",g,s,b,q,w);
break;
case 4: printf("sun xu shu chu:");
printf("%d%d%d%d\n",q,b,s,g);
printf("%d%d%d%d\n",g,s,b,q);
break;
case 3: printf("sun xu shu chu:");
printf("%d%d%d\n",b,s,g);
printf("\ni xu shu chu:");
printf("%d%d%d",g,s,b);
break;
case 2: printf("sun xu shu chu:");
printf("%d%d\n",s,g);
printf("\ni xu shu chu:");
printf("%d%d",g,s);
break;
case 1: printf("%d",g);
}
}
输入的时候必须输入两次``输出的是第一次的结果```