View Code of Problem 9

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

int main() {
	int n, count;
	count = 0;
	while (scanf("%d", &n) != EOF) {
		count++;
		int num[5] = { 0 };
		char s[30];

		for (int i = 0;i < n;i++) {
			scanf("%s",s,30);
			if (strcmp(s,"Pleasant") == 0)
				num[0]++;
			else if (strcmp(s,"Pretty") == 0)
				num[1]++;
			else if (strcmp(s,"Athletic") == 0)
				num[2]++;
			else if (strcmp(s,"Lazy") == 0)
				num[3]++;
			else
				num[4]++;
			scanf("%s", s, 30);
		}
		int su = num[0] + num[1] + num[2] + num[3] + num[4];
		int sum = 5*num[0] + 8*num[1] + 10*num[2] + 15*num[3] + 20*num[4];
		if (su> 9 && (num[2] != 0))
			sum += 50;
		printf("Case #%d: %d\n",count,sum);

	}
	return 0;

}

Double click to view unformatted code.


Back to problem 9