作者在 2008-04-22 18:13:55 发布以下内容
#include<stdio.h>
void main()
{
int a,b,c,d,m,n;
printf("put a number(<1000)\n|");
scanf("%d",&n);
a=n/1000;
b=(n-a*1000)/100;
c=(n-a*1000-b*100)/10;
d=n-a*1000-b*100-c*10;
if(a!=0)
{
printf("the number is 4 i\n");
printf("a=%d\n",a);
printf("b=%d\n",b);
printf("c=%d\n",c);
printf("d=%d\n",d);
m=d*1000+c*100+b*10+a;
printf("m=%d\n",m);
}
else
if(b!=0)
{
printf("the number is 3 i\n");
printf("b=%d\n",b);
printf("c=%d\n",c);
printf("d=%d\n",d);
m=d*100+c*10+b;
printf("m=%d\n",m);
}
else
if(c!=0)
{
printf("the number is 2 i\n");
printf("c=%d\n",c);
printf("d=%d\n",d);
m=d*10+c;
printf("m=%d\n",m);
}
else
if(d!=0)
{
printf("the number is 1 i\n");
printf("d=%d\n",d);
printf("m=%d\n",m);
}
}