输入一个5位数,输出各位数是什么(求解)
输入一个5位数!要求!
输出:它是几位数!
输出:各位数是什么(正序输出)从高到低!如输入1234,输出,1,2,3,4!
输出:(逆向输出),从低到高!如输入1234,输出4321
#include "stdio.h"
main()
{
int x,a,b,c,d,e,y;
printf("please:");
scanf("%d\n",&x);
if(x>0&&x<10)
{
y=1;
printf("ta shi %d wei shu\n",y);
printf("zhen xu shu chu %d\n",x);
printf("nin xu shu chu %d\n",x);
}
if(x>9&&x<100)
{
y=2;
a=x/10;
b=x%10;
printf("ta shi di %d wei shu\n",y);
printf("zhen xu shu chu: %d,%d\n",a,b);
printf("nin xu shu chu:%d%d\n",b,a);
}
if(x>99&&x<1000)
{
y=3;
a=x/100;
b=x/10%10;
c=x%10;
printf("ta shi di %d wei shu\n",y);
printf("zhen xu shu chu: %d,%d,%d\n",a,b,c);
printf("nin xu shu chu:%d%d%d\n",c,b,a);
}
if(x>999&&x<10000)
{
y=4;
a=x/1000;
b=x/100%10;
c=x/10%10;
d=x%10;
printf("ta shi di %d wei shu\n",y);
printf("zhen xu shu chu: %d,%d,%d,%d\n",a,b,c,d);
printf("nin xu shu chu:%d%d%d%d\n",d,c,b,a);
}
if(x>9999&&x<100000)
{
y=5;
a=x/10000;
b=x/1000%10;
c=x/100%10;
d=x/10%10;
e=x%10;
printf("ta shi di %d wei shu\n",y);
printf("zhen xu shu chu: %d,%d,%d,%d,%d\n",a,b,c,d,e);
printf("nin xu shu chu:%d%d\n",e,d,c,b,a);
}
getch();
}
1.为什么输入的时候要输入二次才会显示结果?
2.为什么输入一个5位数的时候就不会显示结果?不管我是用int 还是用long都一样~~~~
本人是菜鸟,希望详细点, 谢谢~```````````