pat甲级打卡-1005 Spell It Right

#include<bits/stdc++.h>
using namespace std;
map<int,string> m={
    {0,"zero"},
    {1,"one"},
    {2,"two"},
    {3,"three"},
    {4,"four"},
    {5,"five"},
    {6,"six"},
    {7,"seven"},
    {8,"eight"},
    {9,"nine"},
};

int main(){
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++) sum+=s[i]-'0';
    string ssum=to_string(sum);
    for(int i=0;i<ssum.length();i++){
        if(i!=0) cout<<" ";
        cout<<m[ssum[i]-'0'];
    } 
    return 0;
}
posted @ 2022-04-21 22:08  秋月桐  阅读(7)  评论(0编辑  收藏  举报