解题思路:用数组来保存每位数字,然后用循环输出数字
注意事项:注意输出的格式
参考代码:
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int a[5];
int i,n,count=0;
cin>>n;
while(n>0)
{
a[count++]=n%10;
n=n/10;
}
printf("%d\n",count);
for(i=count-1;i>0;i--)
printf("%d ",a[i]);
printf("%d\n",a[0]);
for(i=0;i<count;i++)
{
printf("%d",a[i]);
}
return 0;
}
0.0分
0 人评分
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:684 |
C二级辅导-分段函数 (C语言代码)浏览:566 |
C二级辅导-等差数列 (C语言代码)浏览:591 |
C语言程序设计教程(第三版)课后习题12.1 (C语言代码)浏览:987 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:590 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:436 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:277 |
简单的a+b (C++语言代码)浏览:860 |
大小写转换 (C语言代码)浏览:859 |
拆分位数 (C语言代码)浏览:1328 |