码迷,mamicode.com
首页 > 其他好文 > 详细

1005 Spell It Right (20)

时间:2015-02-01 00:27:34      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

 1 #include <string>
 2 #include <sstream>
 3 #include <iostream>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     string str;
 9     char num[10][6]={"zero","one","two","three","four","five","six","seven","eight","nine"};
10     while(getline(cin,str))
11     {
12         int sum=0;
13         for(int i=0;i<str.length();i++)
14             sum+=str[i]-0;
15         string result;
16         stringstream ss;
17         ss<<sum;
18         ss>>result;
19 
20         for(int i=0;i<result.length();i++)
21         {
22             if(i==0) printf("%s",num[ result[i]-0 ]);
23             else  printf(" %s",num[ result[i]-0 ]);
24             //printf("%c",result[i]);
25         }
26         printf("\n");
27     }
28     return 0;
29 }

 

1005 Spell It Right (20)

标签:

原文地址:http://www.cnblogs.com/xiaoyesoso/p/4264932.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!