#include <stdio.h> #include <string.h> int main(){ int n,score=0,num=1; int flag=0; char sheep[10000][10]={{'\0'}},goat[10]={'\0'}; while(scanf("%d",&n) != EOF){ for(int i=0;i < n; i++){ scanf("%s%s",&sheep[i],&goat[i]) if(strcmp(sheep[i], "Pleasant")==0) score += 5; else if(strcmp(sheep[i], "Pretty")==0) score += 8; else if(strcmp(sheep[i], "Athletic")==0) { score += 10; flag = 1; } else if(strcmp(sheep[i], "Lazy")==0) score += 15; else if(strcmp(sheep[i], "Slow")==0) score += 20; } if(n >= 10 && flag==1) score += 50; printf("Case #%d: %d\n",&num,&score); num++; score=0; flag=0; } return 0; } /* Main.c: In function 'main': Main.c:11:8: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[10]' [-Wformat=] scanf("%s%s",&sheep[i],&goat[i]) ^ Main.c:12:6: error: expected ';' before 'if' if(strcmp(sheep[i], "Pleasant")==0) ^ Main.c:14:9: error: 'else' without a previous 'if' else if(strcmp(sheep[i], "Pretty")==0) ^ Main.c:28:5: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int *' [-Wformat=] printf("Case #%d: %d\n",&num,&score); ^ Main.c:28:5: warning: format '%d' expects argument of type 'int', but argument 3 has type 'int *' [-Wformat=] */ |
Double click to view unformatted code.