3934 - A simple problem
时间限制 : 1 秒
内存限制 : 128 MB
Now,give you a natural number N(N<10^100),you need calculate the sum of every digit,then write down every digit of the Chinese phonetic alphabet(Pin yin)
题目输入
In the first line of input file, there's a positive integer T(≤10) indicating how much data sets will be included
each line contain many digit
题目输出
every Pin yin need a space but the last don't need print space.Don't forget print "\n" for every case
输入/输出样例
输入格式
2 1234567890987654321123456789 2333333
输出格式
yi san wu er ling
C++解答
#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> using namespace std; char s[1005]; char ans[20][10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"}; int res[15]; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); int t; scanf("%d",&t); while(t--) { scanf("%s",s); int sum=0; int len=strlen(s); for(int i=0;i<len;i++) { sum=sum+s[i]-'0'; } int cnt=0; while(sum) { res[cnt++]=sum%10; sum/=10; } for(int i=cnt-1;i>=1;i--) { printf("%s ",ans[res[i]]); } printf("%s\n",ans[res[0]]); } return 0; }