int main() { char num[10][7]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int t,flag,sum,len=0,a[10]={0}; char str[7]; scanf("%d",&t); while(t--) { sum=0; scanf("%d",&flag); while(scanf("%s",str)!=EOF) { if(str[0]>='0'&&str[0]<='9') { len=strlen(str); for(int i=0;i<len;i++) { a[i]=str[i]-'0'; } } else if(str[0]=='+') { for(int i=0;i<len;i++) { sum+=a[i]*pow(10,len-i-1); } len=0; } else if(str[0]=='=') { for(int i=0;i<len;i++) { sum+=a[i]*pow(10,len-i-1); } if(flag==0) { printf("%d\n",sum); } else { while(sum>=10) { printf("%s ",num[sum/10]); sum%=10; } printf("%s\n",num[sum]); } len=0; break; } else { for(int i=0;i<10;i++) { if(strcmp(str,num[i])==0) { a[len++]=i; break; } } } } } } /* Main.c: In function 'main': Main.c:6:2: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] scanf("%d",&t); ^~~~~ Main.c:6:2: warning: incompatible implicit declaration of built-in function 'scanf' Main.c:6:2: note: include '<stdio.h>' or provide a declaration of 'scanf' Main.c:1:1: +#include <stdio.h> int main() Main.c:6:2: scanf("%d",&t); ^~~~~ Main.c:11:26: error: 'EOF' undeclared (first use in this function) while(scanf("%s",str)!=EOF) ^~~ Main.c:11:26: note: 'EOF' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'? Main.c:11:26: note: each undeclared identifier is reported only once for each function it appears in Main.c:15:9: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] len=strlen(str); ^~~~~~ Main.c:15:9: warning: incompatible implicit declaration of built-in function 'strlen' Main.c:15:9: note: include '<string.h>' or provide a declaration of 'strlen' Main.c:1:1: +#include <string.h> int main() Main.c:15:9: len=strlen(str); ^~~~~~ Main.c:25:16: warning: implicit declaration of function 'pow' [-Wimplicit-function-declaration] sum+=a[i]*pow(10,len-i-1); ^~~ Main.c:25:16: warning: incompatible implicit declaration of built-in function 'pow' Main.c:25:16: note: include '<math.h>' or provide a declaration of 'pow' Main.c:1:1: +#include <math.h> int main() Main.c:25:16: sum+=a[i]*pow(10,len-i-1); ^~~ Main.c:33:16: warning: incompatible implicit declaration of built-in function 'pow' sum+=a[i]*pow(10,len-i-1); ^~~ Main.c:33:16: note: include '<math.h>' or provide a declaration of 'pow' Main.c:37:6: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] printf("%d\n",sum); ^~~~~~ Main.c:37:6: warning: incompatible implicit declaration of built-in function 'printf' Main.c:37:6: note: include '<stdio.h>' or provide a declaration of 'printf' Main.c:43:7: warning: incompatible implicit declaration of built-in function 'printf' printf("%s ",num[sum/10]); ^~~~~~ Main.c:43:7: note: include '<stdio.h>' or provide a declaration of 'printf' Main.c:46:6: warning: incompatible implicit declaration of built-in function 'printf' printf("%s\n",num[sum]); ^~~~~~ Main.c:46:6: note: include '<stdio.h>' or provide a declaration of 'printf' Main.c:55:9: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration] if(strcmp(str,num[i])==0) ^~~~~~ */ |
Double click to view unformatted code.