View Code of Problem 9

#include<stdio.h>
#include<string.h>
int main()
{
	int n,sum,flag,k=1;
	char goat[20];
	char a[]="Pleasant goat";
	char b[]="Pretty goat";
	char c[]="Athletic goat";
	char d[]="Lazy goat";
	char e[]="Slow goat";
	while(scanf("%d",&n)!=EOF)
	{
		sum=0;
		flag=0;
		if(n>=10)
			flag++;
		getchar();
		while(n--)
		{
			gets(goat);
			if(strcmp(goat,a)==0)
				sum+=5;
			if(strcmp(goat,b)==0)
				sum+=8;
			if(strcmp(goat,c)==0)
			{
				sum+=10;
				flag++;
			}
			if(strcmp(goat,d)==0)
				sum+=15;
			if(strcmp(goat,e)==0)
				sum+=20;
		}
		if(flag==2)
			sum+=50;
		printf("Case #%d: %d\n",k++,sum);
	}
}

Double click to view unformatted code.


Back to problem 9