View Code of Problem 9

#include <iostream>
using namespace std;
int main(){
	int t=0,n;
	while(scanf("%d",n)!=EOF){
		t++;
		string str;
		int goal = 0;
		bool feiyangyang = false;
		cin.ignore(1);
		for(int i=0;i<n;i++){
			getline(cin,str);
			//cout<<str<<endl;
			if(str == "Pleasant goat"){
				goal += 5;
			}
			else if(str == "Pretty goat"){
				goal += 8;
			}
			else if(str == "Athletic goat"){
				goal += 10;
				feiyangyang = true;
			}
			else if(str == "Lazy goat"){
				goal += 15;
			}
			else if(str == "Slow goat"){
				goal += 20;
			}				
		}
		if(n>=10&&feiyangyang){
			goal += 50;
		}
		cout<<"Case #"<<t<<": "<<goal<<endl;
	}
}

Double click to view unformatted code.


Back to problem 9