解题思路:
将每位数分给一个数组元素在进行判断
注意事项:
有点笨的方法
参考代码:
#include<iostream>
using namespace std;
int main(){
int a;
int b[5];
int j=0;
cin>>a;
b[0]=a%10;//gewei
b[1]=a%100/10;//shiwei
b[2]=a%1000/100;//baiwei
b[3]=a%10000/1000;//qianwei
b[4]=a/10000;//wanwei
for(int i=0;i<5;i++)
{
if(b[i]!=0)
{ j++;
}
}
cout<<j<<endl;
for(int i=0;i<j;i++)
{if(b[i]!=0)
{ cout<<b[j-i-1];}
cout<<" ";
}
cout<<endl;
for(int i=0;i<j;i++)
{if(b[i]!=0)
{ cout<<b[i];}
}
}
0.0分
0 人评分
C语言训练-求函数值 (C语言代码)浏览:931 |
【明明的随机数】 (C++代码)浏览:779 |
母牛的故事 (C语言代码)浏览:435 |
计算质因子 (C++代码)浏览:1606 |
C语言训练-大、小写问题 (C语言代码)浏览:724 |
C语言程序设计教程(第三版)课后习题6.5 (C++代码)浏览:447 |
The 3n + 1 problem (C语言代码)浏览:548 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:552 |
1118(求助_已解决)浏览:329 |
杨辉三角 (C语言代码)浏览:484 |