标签:lin ati and end cout main contain nta amp
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.
Input Specification:
Each input file contains one test case. Each case occupies one line which contains an N (≤10100).
Output Specification:
For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.
Sample Input:
12345
Sample Output:
one five
计算数字N的每一位合,然后用英语读每一位。
#include <iostream>
using namespace std;
int main() {
long long sum = 0;
string n;
cin >> n;
for(int i=0;i<n.size();i++) sum+=(n[i]-'0');
string ans = to_string(sum);
string tamp[10] = {"zero","one","two","three","four","five","six","seven","eight","nine"};
for(int i=0;i<ans.size();i++) {
if(i) cout << " ";
cout << tamp[ans[i]-'0'];
}
return 0;
}
标签:lin ati and end cout main contain nta amp
原文地址:https://www.cnblogs.com/F4lc0n/p/12235207.html