|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 936241151 于 2020-10-27 15:42 编辑
#include<stdio.h>
int main()
{ long int num;
int indiv,ten,hundred,thousand,ten_thousand,place;
scanf("%ld",&num);
if(num<=0||num>=100000){
printf("error data");
exit(0);}
else if (num>9999&&num<100000) place=5;
else if (num>999&&num<10000) place=4;
else if (num>99&&num<1000) place=3;
else if (num>9&&num<100) place=2;
else place=1;
printf("%d\n",place);
ten_thousand=num/10000;
thousand=num/1000%10;
hundred=num/100%10;
ten=num%100/10;
indiv=num%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\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;
}
return 0;
}
这是pintia上的一道题,总是说答案错误,求大神改正
程序第8行使用了 exit(),而没有添加头文件,#include<windows.h>
|
|