题目描述
把正整数按位进行输出。
输入
输入文件中每行为一个正整数n。
输出
把整数n按位输出,从低到高。
样例输入 复制
0
999
123
样例输出 复制
0 has one number,is 0
999 have three numbers,are 9,9,9
123 have three numbers,are 3,2,1
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int main()
{
int n;
vector<string> str = {"zero","one","two","three","four","five","six","seven","eight","nine","ten"};
while(scanf("%d",&n)!=EOF)
{
int len = 0;
int tem = n;
int a[1000];
while(n)
{
a[len] = n%10;
n/=10;
len++;
}
if(len==0)
{
printf("%d has one number,is %d",tem,tem);
}
if(len==1)
{
printf("%d has one number,is %d",tem,tem);
}
if(len>1)
{
printf("%d have ",tem);
cout<<str[len];
printf(" numbers,are ");
for(int i = 0;i<len-1;i++)
printf("%d,",a[i]);
printf("%d",a[len-1]);
}
cout<<endl;
}
return 0;
}