View Code of Problem 9

#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	int k = 1;
	int score = 0, flag = 0;
	while (cin >> n) {
		int keep_n = n;
		while (n--) {
			string str1, str2;
			cin >>str1 >> str2;
			if (str1 == "Pleasant"&&str2 == "goat") {
				score += 5;
			}
			else if (str1 == "Pretty"&&str2 == "goat") {
				score += 8;
			}
			else if (str1 == "Athletic"&&str2== "goat") {
				score += 10;
				flag = 1;
			}
			else if (str1 == "Lazy"&&str2== "goat") {
				score += 15;
			}
			else {
				score += 20;
			}
		}
		if (keep_n >= 10 && flag == 1)
			score += 50;
		cout << "Case #" << k << ": " << score << endl;
		k++;
		score = 0, flag = 0;
	}
}

Double click to view unformatted code.


Back to problem 9