标签:def close return break a+b c代码 txt pac iostream
AC代码:
#include <iostream> #include <cstdio> #include <cstring> #define Max 105 using namespace std; int main(void) { freopen("in.txt","r",stdin); int i,j,sum1,sum2,flag,a,len; char s[Max],s1[Max]; while(gets(s)!=NULL) { len=strlen(s); sum1=sum2=0; flag=0; for(i=0,j=0;i<len;i++) { if(s[i]>=‘a‘&&s[i]<=‘z‘) s1[j++]=s[i]; if(s[i]==‘ ‘&&s[i-1]!=‘+‘) { s1[j]=‘\0‘; if(!strcmp(s1,"zero")) a=0; else if(!strcmp(s1,"one")) a=1; else if(!strcmp(s1,"two")) a=2; else if(!strcmp(s1,"three")) a=3; else if(!strcmp(s1,"four")) a=4; else if(!strcmp(s1,"five")) a=5; else if(!strcmp(s1,"six")) a=6; else if(!strcmp(s1,"seven")) a=7; else if(!strcmp(s1,"eight")) a=8; else if(!strcmp(s1,"nine")) a=9; j=0; if(!flag) sum1=sum1*10+a; else sum2=sum2*10+a; } else if(s[i]==‘+‘) flag=1; } if(sum1==0&&sum2==0) break; printf("%d\n",sum1+sum2); } fclose(stdin); return 0; }
标签:def close return break a+b c代码 txt pac iostream
原文地址:https://www.cnblogs.com/phaLQ/p/10046658.html