switch语句问题
#include<stdio.h>void main()
{
int num;
int indiv,ten,hundred,thousand;
int ten_thousand,hundred_thousand,place;
printf("请输入一个整数1-99999:");
scanf("%d\n",&num);
if(num>99999)
place=6;
else if (num>9999)
place=5;
else if(num>999)
place=4;
else if(num>99)
place=3;
else if(num>9)
place=2;
else
place=1;
printf("每位数字为:%d\n",place);
hundred_thousand=num/100000;
ten_thousand=(num-hundred_thousand*10000)/10000;
thousand=(num-num*hundred_thousand-num*ten_thousand)/1000;
hundred=(num-num*hundred_thousand-num*ten_thousand-thousand*1000)/100;
ten=(num-num*hundred_thousand-num*ten_thousand-thousand*1000-hundred*100)/10;
indiv=num-num*hundred_thousand-num*ten_thousand-thousand*1000-hundred*100-ten*10;
switch(place)
{
case 1:printf("%d",indiv);
printf("反序数字为:%d\n",indiv);
break;
case 2:printf("%d,%d\n",indiv,ten);
printf("反序数字为:%d,%d\n",ten,indiv);
break;
case 3:printf("%d,%d,%d\n",indiv,ten,hundred);
printf("反序数字为:%d,%d,%d\n",hundred,ten,indiv);
break;
case 4:printf("%d,%d,%d,%d\n",indiv,ten,hundred,thousand);
printf("反序数字为:%d,%d,%d,%d\n",thousand,hundred,ten,indiv);
break;
case 5:printf("%d,%d,%d,%d,%d\n",indiv,ten,hundred,thousand,ten_thousand);
printf("反序数字为:%d,%d,%d.%d,%d\n",ten_thousand,thousand,hundred,ten,indiv);
break;
case 6:printf("%d,%d,%d,%d,%d,%d\n",indiv,ten,hundred,thousand,ten_thousand,hundred_thousand);
printf("反序数字为:%d,%d,%d,%d,%d,%d\n",hundred_thousand,ten_thousand,thousand,hundred,ten,indiv);
break;
default:printf("not find .\n");
}
}
这是一个:给出一个不多于5位的正整数,要求它是几位数,分别打出每一位数字,按倒序打出各位数字,例如984变成489.上面是我写的,但是不知道错在哪了,莱鸟的我第一打这么长的,辛苦。