ACM乐园
Love Me,Love My Code!
posts - 53,  comments - 24,  trackbacks - 0
http://acm.hdu.edu.cn/showproblem.php?pid=1228

依然是水题,就是写的多而已,据说是浙大研究生复试题,就是练习速度的。头文件写多了。。。。

代码如下:

#include <iostream>
#include 
<algorithm>
#include 
<string>
#include 
<set>
#include 
<cmath>
#include 
<iomanip>
using namespace std;

int change(string str)
{
    
if(str=="one")
        
return 1;
    
if(str=="two")
        
return 2;
    
if(str=="three")
        
return 3;
    
if(str=="four")
        
return 4;
    
if(str=="five")
        
return 5;
    
if(str=="six")
        
return 6;
    
if(str=="seven")
        
return 7;
    
if(str=="eight")
        
return 8;
    
if(str=="nine")
        
return 9;
    
if(str=="zero")
        
return 0;
}


int main()
{
    
string str1,str2,str3,str4,str5,str6;
    
int s1,s2;
    
while(cin>>str1>>str2>>str3>>str4)
    
{
        
if(str1=="zero" && str3=="zero")
            
break;
        
if(str2!="+")
        
{
            s1
=change(str1)*10+change(str2);
            cin
>>str5;
            
if(str5!="=")
            
{
                s2
=change(str4)*10+change(str5);
                cin
>>str6;
            }

            
else
                s2
=change(str4);
        }

        
else
        
{
            s1
=change(str1);
            
if(str4!="=")
            
{
                s2
=change(str3)*10+change(str4);
                cin
>>str5;
            }

            
else
                s2
=change(str3);
        }

        cout
<<s1+s2<<endl;

    }

    
return 0;
}
posted on 2011-04-01 22:51 大大木马 阅读(183) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2011年4月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(1)

随笔档案(53)

文章档案(2)

搜索

  •  

积分与排名

  • 积分 - 62448
  • 排名 - 352

最新评论

阅读排行榜

评论排行榜