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

题目594-还是A+B-nyoj20140816

时间:2014-08-16 16:25:50      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:io   ar   2014   on   sp   har   return   c   

#include <stdio.h> #include <string.h>

int zhuanhuan(char str[20])

{     if(strcmp(str,"zero")==0)

    return 0;    

if(strcmp(str,"one")==0)     return 1;    

if(strcmp(str,"two")==0)     return 2;   

 if(strcmp(str,"three")==0)     return 3;    

if(strcmp(str,"four")==0)     return 4;    

if(strcmp(str,"five")==0)     return 5;    

if(strcmp(str,"six")==0)     return 6;    

if(strcmp(str,"seven")==0)     return 7;    

if(strcmp(str,"eight")==0)     return 8;    

if(strcmp(str,"nine")==0)     return 9;     }

int main()

{     char str1[20],str2[20],str3[20];    

char str4[20],str5[20],str6[20];    

while(scanf("%s",str1)!=EOF)    

{        

int sum1,sum2,sum3,sum4,sum5,sum;        

sum1=zhuanhuan(str1);        

scanf("%s",str2);        

if(strcmp(str2,"+")!=0)        

{            

sum2=zhuanhuan(str2);            

scanf("%s",str3);            

scanf("%s",str4);            

sum4=zhuanhuan(str4);            

scanf("%s",str5);            

if(strcmp(str5,"=")!=0)            

{                

sum5=zhuanhuan(str5);                

scanf("%s",str6);                

sum=10*sum1+sum2+10*sum4+sum5;                

printf("%d\n",sum);            

}            

else{                

sum=10*sum1+sum2+sum4;                

printf("%d\n",sum);                

}        

}            

else            

{                

scanf("%s",str3);                

sum3=zhuanhuan(str3);                

scanf("%s",str4);                

if(strcmp(str4,"=")!=0)                

{                    

sum4=zhuanhuan(str4);                    

scanf("%s",str5);                    

sum=sum1+10*sum3+sum4;                    

printf("%d\n",sum);                    

}                    

else                    

{                        

sum=sum1+sum3;                        

printf("%d\n",sum);                        

}                                

}                        

}        

return 0;    

}

题目594-还是A+B-nyoj20140816,布布扣,bubuko.com

题目594-还是A+B-nyoj20140816

标签:io   ar   2014   on   sp   har   return   c   

原文地址:http://www.cnblogs.com/xiaziteng/p/3916493.html

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