求大神。。OJ上说我wrong answer,可是devc++弄出来是对的。用c语言的,数字分析
输入一个不多于5位的正整数,要求:(1)求出它是几位数;
(2)分别输出每一位数字;
(3)按逆序输出各位数字;
(4)判断逆序后的数字是奇数或偶数,是奇数输出1,是偶数输出0。
注意:最后一行输出后不要再输出回车换行符。
输入样例:
23461
输出样例:
5
2 3 4 6 1
16432
0
#include <stdio.h>
#include <stdlib.h>
main()
{ int num,num1,indiv,ten,hundred,thousand,ten_thousand,place;
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);
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);
num1=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);
num1=printf("%d%d%d%d\n",indiv,ten,hundred,thousand);
break;
case 3: printf("%d %d %d\n",hundred,ten,indiv);
num1=printf("%d%d%d\n",indiv,ten,hundred);
break;
case 2: printf("%d %d\n",ten,indiv);
num1=printf("%d%d\n",indiv,ten);
break;
case 1: printf("%d\n",indiv);
num1=printf("%d\n",indiv);
break;
}
if(num1%2==0)printf("0");
else printf("1");
system("PAUSE");
return 0;
}