View Code of Problem 9

#include<stdio.h>
#include<string.h>
int main(){
	int T = 0;
	
	int count = 0;
	int sheeps;
	while(scanf("%d",&sheeps)!=EOF){
		int score = 0;
		count++;
		//getchar();
		int flag=0;
		char sheep_name[15];
		getchar();
		for(int i=0;i<sheeps;i++){
			int j=0;
			
			while(1){
				char tem;
				scanf("%c",&tem);
				sheep_name[j]=tem;
				if(tem=='\n'){
					sheep_name[j]='\0';
					break;
				}
				j++;
			}
			if(!strcmp(sheep_name,"Pleasant goat")){
				score+=5;
			}else if(!strcmp(sheep_name,"Pretty goat")){
				score+=8;
			}else if(!strcmp(sheep_name,"Athletic goat")){
				score+=10;
				flag=1;
			}else if(!strcmp(sheep_name,"Lazy goat")){
				score+=15;
			}else if(!strcmp(sheep_name,"Slow goat")){
				score+=20;
			}
		}
		if(sheeps>=10&&flag==1){
			score+=50;
		}
		printf("Case #%d: %d\n",count,score);
	}
}

Double click to view unformatted code.


Back to problem 9