拼写正确
给定一个非负整数 N,你的任务是计算 N 的所有数字的总和,并以英语输出总和的每个数字。
输入格式
共一行,包含一个整数 N 。
输出格式
共一行,用英语输出总和的每个数字,单词之间用空格隔开。
数据范围
0≤N≤10100
输入样例:
12345
输出样例:
one five
C++ 代码
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
string m[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
string s1;
cin >> s1;
int t = 0 ;
for(auto s : s1)
{
t += s-'0';
}
string s2 = to_string(t);
for(auto s : s2)
{
string x = m[s-'0'];
cout<<x<<" ";
}
cout<<endl;
}