View Code of Problem 9

#include "stdlib.h"
#include "iostream"
#include "string.h"
using namespace std;
int main()
{
	int n = 0; char str[100]; int k = 0;
	while (cin>>n)
	{
		k++;
		int goal = 0; int flag = 0;
		for (int i = 0; i < n; i++)
		{
			getchar();
			scanf("%[^\n]", &str);
			if (str[0] == 'P' && str[1]=='l')goal += 5;
			else if (str[0] == 'P' && str[1] == 'r')goal += 8;
			else if (str[0] == 'L' )goal += 15;
			else if (str[0] == 'S' )goal += 20;
			else if (str[0] == 'A')
			{
				goal += 10;
				flag=1;
			}
		}
		if (n >= 10 && flag == 1)goal += 50;
		cout << "Case #" << k++ << ": " << goal << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 9