PAT字符处理题---1002 写出这个数 (20分)

1002 写出这个数 (20分)

[1002 写出这个数 (20分)](https://pintia.cn/problem-sets/994805260223102976/problems/994805324509200384)
#include<iostream>
#include<string>

using namespace std;

string name[10]={"ling","yi","er","san","si","wu"
				,"liu","qi","ba","jiu"};
int main(){
	string s; cin>>s;
	int sum=0;
	for(int i=0;i<s.length();i++){
		sum+=s[i]-'0';
	}
	string a=to_string(sum);
	for(int i=0;i<a.length();i++){
		if(i) cout<<" ";
		cout<<name[a[i]-'0'];
	}
	return 0;
}
上一篇:狂人日记


下一篇:PAT 1002 A+B for Polynomials (25分)