View Code of Problem 9

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

Double click to view unformatted code.


Back to problem 9