本文共 729 字,大约阅读时间需要 2 分钟。
题目要求:
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解题思路:此题较为简单,只需要使用一个字符串存储输入,然后将每一位相加,按照要求输出即可。使用字符串是为了更方便的相加
参考代码:
#includeusing namespace std;int main(){ string s; //使用字符串获取输入,这样方便拆解 cin>>s; int sum = 0; for(int i=0;i =0;j--) { cout <
转载地址:http://mbzfi.baihongyu.com/