View Code of Problem 9

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(){
	int n;
	char tmp[20];
	int a[5];
	int sum;
	int i,j,flag=0,k=1;
	while(scanf("%d",&n)!=EOF){
		for(i=0;i<5;i++){
			a[i]=0;
		}
		sum=0;
		j=n;
		while(n>0){
			fflush(stdin);
			gets(tmp);
			if(strcmp(tmp,"Pleasant goat")==0)
				a[0]++;
			else if(strcmp(tmp,"Pretty goat")==0)
				a[1]++;
			else if(strcmp(tmp,"Athletic goat")==0){
				a[2]++;
				flag=1;
			}
			else if(strcmp(tmp,"Lazy goat")==0)
				a[3]++;
			else if(strcmp(tmp,"Slow goat")==0)
				a[4]++;
			n--;

		}
		sum=a[0]*5+a[1]*8+a[2]*10+a[3]*15+a[4]*20;
		if(j>=10&&flag==1)
			sum+=50;
		printf("Case #%d: %d\n",k,sum);
		k++;
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 9