View Code of Problem 9

#include<stdio.h>
#include<math.h>
#include<string.h>
typedef struct goat{
	char str[15];
	int score;
}goat;
int main()
{
    int n; 
    goat g[5];
    strcpy(g[0].str,"Pleasant");
    g[0].score=5;
    strcpy(g[1].str,"Pretty");
    g[1].score=8;
    strcpy(g[2].str,"Athletic");
    g[2].score=10;
    strcpy(g[3].str,"Lazy");
    g[3].score=15;
    strcpy(g[4].str,"Slow");
    g[4].score=20;
    int cnt=1;
    while(scanf("%d",&n)!=EOF)
    {
       int count[5],i,j;
       for(i=0;i<5;i++)
         count[i]=0;
       char s[15];
       int sum=0;
       for(i=0;i<n;i++)
       {
       	  scanf("%s",s);
       	  for(j=0;j<5;j++)
       	  {
       	  	if(strcmp(s,g[j].str)==0)
       	  	{
       	  		count[j]++;
       	  		sum+=g[j].score;
       	  		break;
			}
		  }
		  scanf("%s",s);
	   }
	   if(n>=10&&count[2]!=0)
	     sum+=50;
	    printf("Case #%d: %d\n",cnt,sum);
	    cnt++;
	}
}

Double click to view unformatted code.


Back to problem 9