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
#include <iostream>#include<string>using namespacestd;intMain () {stringnum; Chartemp[7]; intsize,sum=0; CIN>>num; Size=num.size (); int*a=New int[size]; for(intI=0; i<size;i++) {A[i]=num[i]- -; } for(intI=0; i<size;i++) {sum+=A[i]; } //cout<<sum;sprintf (temp,"%d", sum); stringSumnum (temp); Size=sumnum.size (); for(intI=0; i<size;i++){ Switch(Sumnum[i]) { Case '0':cout<<"Ling"; Break; Case '1':cout<<"Yi"; Break; Case '2':cout<<"er"; Break; Case '3':cout<<"San"; Break; Case '4':cout<<"si"; Break; Case '5':cout<<"Wu"; Break; Case '6':cout<<"Liu"; Break; Case '7':cout<<"Qi"; Break; Case '8':cout<<"BA"; Break; Case '9':cout<<"JIU"; Break; }; if(i!=size-1) {cout<<" "; }} Delete [] A; return 0;}
PAT (Basic level) 1002. Write this number (20)