PAT A1005

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:
Sample Output:
one five

#include "stdio.h"
//#include "math.h"
#include "string.h"
//#include "algorithm"
//using namespace std;
char map[10][7]={"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int main(){
    char str[110];
    int sum = 0,len = (int)strlen(str);
    for (int i = 0; i < len; i++) {
        sum += str[i] - '0';
    int num = 0,ans[31];
        ans[num++] = sum %10;
        sum /= 10;
    for (int i = num - 1; i >= 0; i--) {
        printf("%s", map[ans[i]]);
        if (i) {
            printf(" ");
    return 0;

本题类似PAT B1002,只不过把map表从yi er san…换成了one two three…