首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

二零零五年第1题

2013-11-08 
2005年第1题地址:http://ac.jobdu.com/problem.php?pid1010C语言源码:#includestdio.h#includestring.

2005年第1题

地址:http://ac.jobdu.com/problem.php?pid=1010

C语言源码:

#include<stdio.h>#include<string.h>int main(){char S[100];int a,b;a=1;b=1;while(a!=0||b!=0){a=0;b=0;scanf("%s",S);getchar();while(strcmp(S,"+")!=0){a=a*10;if(strcmp(S,"one")==0)a=a+1;elseif(strcmp(S,"two")==0)a=a+2;elseif(strcmp(S,"three")==0)a=a+3;elseif(strcmp(S,"four")==0)a=a+4;elseif(strcmp(S,"five")==0)a=a+5;elseif(strcmp(S,"six")==0)a=a+6;elseif(strcmp(S,"seven")==0)a=a+7;elseif(strcmp(S,"eight")==0)a=a+8;elseif(strcmp(S,"nine")==0)a=a+9;scanf("%s",S);getchar();}while(strcmp(S,"=")!=0){b=b*10;if(strcmp(S,"one")==0)b=b+1;elseif(strcmp(S,"two")==0)b=b+2;elseif(strcmp(S,"three")==0)b=b+3;elseif(strcmp(S,"four")==0)b=b+4;elseif(strcmp(S,"five")==0)b=b+5;elseif(strcmp(S,"six")==0)b=b+6;elseif(strcmp(S,"seven")==0)b=b+7;elseif(strcmp(S,"eight")==0)b=b+8;elseif(strcmp(S,"nine")==0)b=b+9;scanf("%s",S);getchar();}if(a!=0||b!=0)printf("%d\n",a+b);}}


热点排行