数字各位相加和转字符
1. 原文
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 (≤$10^{100}$).
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:
1 | 12345 |
Sample output:
1 | one five |
2. 解析
将正整数N的每位数相加,和以英文输出
如:12345 -> 1+2+3+4+5=15 -> one five
Solution:
以字符串的形式输入,防止数字过大,int/long long整型越界。
加每一位的字符 str[i]-‘0’
取和的每位数值后输出
3. AC代码
1 |
|