View Code of Problem 9

#include <stdio.h>
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int main()
{
	char str[20];
	int n, i, j, sum,k=0;
	scanf("%d", &n);
	while (scanf("%d",&n)!=EOF)
	{
		k++;
		sum = 0;
		int flag = 0;
		for (i = 0; i <n; i++)
		{
			scanf("%s", str);
			while (getchar() != '\n')
				continue;
			if (str[0] == 'P')
			{
				if (str[1] == 'l')
					sum += 5;
				else sum += 8;
			}
			else if (str[0] == 'A')
			{
				sum += 10;
				flag = 50;
			}
			else if (str[0] == 'L')
				sum += 15;
			else sum += 20;
		}
		if (n >= 10)
			sum += flag;
		printf("Case #%d: %d\n", k, sum);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 9