1002 写出这个数 (20 分)

水题~。

string mp[]={"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.size();i++) sum+=(s[i]-'0');

   vector<string> res;
   while(sum)
   {
       int t=sum%10;
       res.pb(mp[t]);
       sum/=10;
   }
   reverse(res.begin(),res.end());

   for(int i=0;i<res.size();i++)
        if(i) cout<<' '<<res[i];
        else cout<<res[i];
    cout<<endl;

   //system("pause");
    return 0;
}
posted @ 2021-02-13 10:46  Dazzling!  阅读(28)  评论(0编辑  收藏  举报