|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<math.h>
int main()
{
int num,indiv,ten,hundred,thousand,ten_thousand,place;
printf("请输入一个0~99999之间的整数: ");
scanf("%d",&num);
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);
printf("此数的每一位分别是:");
ten_thousand=num/10000;
thousand=(int)(num-ten_thousand*10000)/1000;
hundred=(int)(num-ten_thousand*10000-thousand*1000)\100;
ten=(int)(num-ten_thousand*10000-thousand*1000-hundred*100)\10;
indiv=(int)(num-ten_thousand*10000-thousand*1000-hundred*100-ten*10);
switch(place)
{
case 5:printf("%d,%d,%d,%d,%d\n",ten_thousand,thousand,hundred,ten,indiv);
printf("此数逆序输出为%d,%d,%d,%d,%d\n",indiv,ten,hundred,thousand,ten_thousand);break;
case 4:printf("%d,%d,%d,%d,%d\n",thousand,hundred,ten,indiv);
printf("此数的逆序输出为%d,%d,%d,%d\n",indiv,ten,hundred,thousand); break;
case 3:printf("%d,%d,%d\n",hundred,ten,indiv);
printf("此数的逆序输出为%d,%d,%d\n",indiv,ten,hundred); break;
case 2:printf("%d,%d\n",ten,indiv);
printf("此数的逆序输出为%d,%d\n",indiv,ten); break;
case 1:printf("%d\n",indiv);
printf("此数的逆序输出为%d\n",indiv); break;
}
}
此程序我一运行它就提示我语法错误少了分号,错误提示行就是我用红色标出来的那里,但我分号一个都没掉呀,也看不出到底哪里出了问题 晕晕晕
|
|