View Code of Problem 9

#include <stdio.h>
#include <string.h>


int main()
{
	int num, i,sum = 0, count = 0, tag;
	char str[20];
	while(scanf("%d", &num) != EOF){
		getchar();
		count++;
		sum = 0;
		tag = 0;
		for(i=0; i<num; ++i){
			scanf("%[^\n]", str);
			getchar();
			if(!strcmp(str, "Pleasant goat"))
				sum += 5;			
			else if(!strcmp(str, "Pretty goat"))
				sum += 8;			
			else if(!strcmp(str, "Athletic goat"))
				sum+= 10;
			else if(!strcmp(str, "Lazy goat")){
				tag =1;
				sum += 15;
			}
			else
				sum += 20;
		}
		if(tag == 1 && num>=10 )
			sum += 50;
		printf("Case #%d: %d\n", count, sum);
		
	} 
	
	
	
	
	return 0;	
}

Double click to view unformatted code.


Back to problem 9