Read in a natural number n, calculate the sum of their numbers, and write each digit in Hanyu Pinyin.
input Format: each test input contains 1 test cases, which gives the value of the natural number N. This guarantees that n is less than 10100.
output format: output n in one line each digit of the sum of the number of digits, there are 1 spaces between the phonetic numerals, but there is no space after the last phonetic number in a row.
Input Sample:
1234567890987654321123456789
Sample output:
Yi San Wu
Since the length of the number is 100 bits, it is natural to use the string class to store it.
After the calculation and after, as long as the recursive output number corresponding Pinyin is good.
Recommended pinyin with an array of storage, save money multiple if miscellaneous code.
Attention to the problem of recursive spatio-temporal lattice
#include <bits/stdc++.h>using namespacestd;Chardigit[Ten][Ten] = {"Ling","Yi","er","San","si","Wu","Liu","Qi","BA","JIU"};voidSolveintx);BOOLFlag =true;intMain () {stringstr; CIN>>str; intCNT =0; intLen =str.length (); for(inti =0; i < Len; ++i) {CNT+ = str[i]-'0'; } solve (CNT); return 0;}voidSolveintx) { if(x = =0){ return; } Solve (x/Ten); if(flag) {flag=false; } Else{printf (" "); } printf ("%s", digit[x%Ten]);}Capouis ' S CODE
Pat-basic-1002-writes this number