View Code of Problem 9

#include<stdio.h> 
//int main()
//{
//	char str[200];char str1[20];int k=0;int n;
//	while(scanf("%d",&n)!=EOF)
//	{
//		int sum=0,flag=0;
//		for(int i=0;i<n;i++)
//		{
//			scanf("%s %s",str,str1);
//			if(str[0]=='P'&&str[1]=='l')
//			{
//				sum+=5;
//			}
//			else if(str[0]=='P'&&str[1]=='r')
//			{
//				sum+=8;
//			}
//			else if(str[0]=='A')
//			{
//				flag=1;
//				sum+=10;
//			}
//			else if(str[0]=='L')
//			{
//				sum+=15;
//			}
//			else if(str[0]=='S')
//			{
//				sum+=20;
//			}
//		}
//		if(n>=10&&flag==1)
//		printf("Case #%d: %d\n",++k,sum+50); 
//		else
//		printf("Case #%d: %d\n",++k,sum);
//	}
//}
#include<string>
#include<iostream>
using namespace std;
int main(){	
	string str,str2;int k=0;int n;
	while(scanf("%d",&n)!=EOF)
	{
		int sum=0,flag=0;
		for(int i=0;i<n;i++)
		{
			cin>>str>>str2;
			if(str=="Pleasant")
			{
				sum+=5;
			}
			else if(str=="Pretty")
			{
				sum+=8;
			}
			else if(str=="Athletic")
			{
				flag=1;
				sum+=10;
			}
			else if(str=="Lazy")
			{
				sum+=15;
			}
			else if(str=="Slow")
			{
				sum+=20;
			}
		}
		if(n>=10&&flag==1)
		printf("Case #%d: %d\n",++k,sum+50); 
		else
		printf("Case #%d: %d\n",++k,sum);
	}
} 

Double click to view unformatted code.


Back to problem 9