View Code of Problem 9

#include "stdlib.h"
#include "iostream"
#include "string.h"
using namespace std;
int main()
{
	int n = 0; char str[999]; int k = 0; int a[999]; int j = 0;
	while (scanf("%d",&n)!=EOF)
	{
		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;
		a[j] = goal;
		j++;
	}
	for (int i = 0; i < n; i++)
	{
		cout << "Case #" << i+1 << ": " << a[i] << endl;
		if (i < n - 1)printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 9