View Code of Problem 9

#include <stdio.h>
#include <string.h>
int main()
{
	int n,sum,i;
	char str1[500],str2[90];
	printf("input n(1<n<1e+4):");
	scanf("%d",&n);
	
	do
	{	int k=1;
                int flag=1;
		sum=0;
		for(i=0;i<n;i++)
		{
		
			printf("input the name of the goat:\n");
		    scanf("%s%s",str1,str2);//接收两个字符串
			if(str1[0]=='P'&&str1[1]=='l')
				sum=sum+5;
			else if(str1[0]=='P'&&str1[1]=='r')
				sum=sum+8;
			else if(str1[0]=='A')
			{
				sum=sum+10;	
				flag=1;
			}
			else if(str1[0]=='L')
				sum=sum+15;
			else if(str1[0]=='S')
				sum=sum+20;
		}
		if(n>=10 && flag==1)
			sum=sum+50;
		printf("Case#%d: %d\n",k++,sum);
	}while(n--);
}

Double click to view unformatted code.


Back to problem 9