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;
}
上一篇:LeedCode刷题:1002.查找常用字符


下一篇:直接缓冲DirectByteBuffer详解