解题思路:
注意事项:
参考代码:
#include<stdio.h>
int main()
{
int x,x1,x2,n=0;
int i;
scanf("%d",&x);
x1=x2=x;
while(x>0)
{
n++;
x=x/10;
}
printf("%d\n",n);
if(n==1)
{
printf("%d",x1);
}
else if(n==2)
{
printf("%d %d",x1/10,x1%10);
}
else if(n==3)
{
printf("%d %d %d",x1/100,x1/10%10,x1%10);
}
else if(n==4)
{
printf("%d %d %d %d",x1/1000,x1/100%10,x1/10%10,x1%10);
}
else if(n==5)
{
printf("%d %d %d %d %d",x1/10000,x1/1000%10,x1/100%10,x1/10%10,x1%10);
}
if(n==1)
{
printf("%d",x1);
}
else if(n==2)
{
printf("\n%d",x1%10*10+x1/10);
}
else if(n==3)
{
printf("\n%d",x1%100%10*100+x1%100/10*10+x1/100);
}
else if(n==4)
{
printf("\n%d",x1%1000%100%10*1000+x1%1000%100/10*100+x1/100%10*10+x1/1000);
}
else if(n==5)
{
printf("\n%d",x1/10000+x1/1000%10*10+x1/100%100%10*100+x1/10%1000%100%10*1000+x1%10*10000);
}
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)scanf后面加个getchar(),收掉回车符,就可以用gets了浏览:1156 |
C语言程序设计教程(第三版)课后习题12.2 (C语言代码)浏览:821 |
简单的a+b (C语言代码)浏览:746 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:452 |
小明A+B (C语言代码)浏览:1268 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:1104 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:557 |
数对 (C语言代码)浏览:717 |
简单的a+b (C语言代码)浏览:435 |
图形输出 (C语言代码)浏览:1394 |