不一定阿,但是说真的,一个程序员必须有耐性,不能浮躁,否则会很吃亏的……
#include<stdio.h>
#include<math.h>
void main()
{
long int number;
int indiv,ten,hund,thou,t_th; /*分别代表个位、十位、百位、千位、万位*/
printf("place input a whole number(0~99999):\n");
scanf("%ld",&number);
if(number<0||number>99999) printf("The date is error\n");
else if(number>9999)printf("place=5");
else if(number>999)printf("place=4");
else if(number>99)printf("place=3");
else if(number>9)printf("place=2");
else printf("place=1");
printf("each number is:");
t_th=number/10000;
thou=(int)(number-t_th*10000)/1000;
hund=(int)(number-t_th*10000-thou*1000)/100;
ten=(int)(number-t_th*10000-thou*1000-hund*100)/10;
indiv=(int)(number-t_th*10000-thou*1000-hund*100-ten*10);
{
if(number>9999)
{printf("%d,%d,%d,%d,%d",t_th,thou,hund,ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d%d%d%d\n",indiv,ten,hund,thou,t_th);
}
else if(number>999)
{printf("%d,%d,%d,%d",thou,hund,ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d%d%d\n",indiv,ten,hund,thou);
}
else if(number>99)
{printf("%d,%d,%d",hund,ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d%d\n",indiv,ten,hund);
}
else if(number>9)
{printf("%d,%d",ten,indiv);
printf("\nThe reverse number is:");
printf("%d%d\n",indiv,ten);
}
else
{printf("%d",indiv);
printf("\nThe reverse number is:");
printf("%d\n",indiv);
}
}
getch();
}