1005 Spell It Right 较简单

代码

#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
string a[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
int main()
{
	string s;
	int cnt;
	cin>>s;
	for(int i=0;s[i]!=NULL;i++){
		cnt+=(s[i]-'0');
	}
	s=to_string(cnt);
	for(int i=0;s[i]!=NULL;i++){
		if(i==0){
			cout<<a[(s[i]-'0')];
		}
		else{
			cout<<" "<<a[(s[i]-'0')];
		}
	}
	return 0;
}
posted @ 2022-07-18 14:34  qwasdasd  阅读(18)  评论(0)    收藏  举报