输入 任意一位不多于5位的整数
1 判断它是几位数
2 分别输出它的每位数字
3 逆序输出这个数字 比如原先是123 逆序输出为321
# include <stdio.h>
void main()
{
int a,b,x1,x2,x3,x4,x5;
a=scanf("%d",&a);
if(a>9999)
printf("The number is 5 digits.\n");
else if(a>999)
printf("The number is 4 digits.\n");
else if(a>99)
printf("The number is 3 digits.\n");
else if(a>9)
printf("The number is 2 digits.\n");
else
printf("The number is 1 digit.\n"); x1=a/10000;
x2=a%10000/1000;
x3=a%1000/100;
x4=a%100/10;
x5=a%10;
if(x1)
{
printf("%d,%d,%d,%d,%d\n",x1,x2,x3,x4,x5);
printf("%d%d%d%d%d\n",x5,x4,x3,x2,x1);
}
else if(x2)
{
printf("%d,%d,%d,%d\n",x2,x3,x4,x5);
printf("%d%d%d%d\n",x5,x4,x3,x2);
}
else if(x3)
{
printf("%d,%d,%d\n",x3,x4,x5);
printf("%d%d%d\n",x5,x4,x3);
}
else if(x4)
{
printf("%d,%d\n",x4,x5);
printf("%d%d\n",x5,x4); }
else
printf("%d",x5);
printf("%d",x5);
}
1 判断它是几位数
2 分别输出它的每位数字
3 逆序输出这个数字 比如原先是123 逆序输出为321
# include <stdio.h>
void main()
{
int a,b,x1,x2,x3,x4,x5;
a=scanf("%d",&a);
if(a>9999)
printf("The number is 5 digits.\n");
else if(a>999)
printf("The number is 4 digits.\n");
else if(a>99)
printf("The number is 3 digits.\n");
else if(a>9)
printf("The number is 2 digits.\n");
else
printf("The number is 1 digit.\n"); x1=a/10000;
x2=a%10000/1000;
x3=a%1000/100;
x4=a%100/10;
x5=a%10;
if(x1)
{
printf("%d,%d,%d,%d,%d\n",x1,x2,x3,x4,x5);
printf("%d%d%d%d%d\n",x5,x4,x3,x2,x1);
}
else if(x2)
{
printf("%d,%d,%d,%d\n",x2,x3,x4,x5);
printf("%d%d%d%d\n",x5,x4,x3,x2);
}
else if(x3)
{
printf("%d,%d,%d\n",x3,x4,x5);
printf("%d%d%d\n",x5,x4,x3);
}
else if(x4)
{
printf("%d,%d\n",x4,x5);
printf("%d%d\n",x5,x4); }
else
printf("%d",x5);
printf("%d",x5);
}