View Code of Problem 9

#include<stdio.h>   
#include<string.h>
int score(int n);
void main()
{
int x,y,n;
for (x=1;scanf("%d",&n)!=EOF;x++)
printf("Case #%d: %d\n",x,score(n));
}
int score(int n)	
{    int a=0,i,s1=0;
     char str[100];
	 char str1[10];
	 char view[][20]={"Pleasant","Pretty","Athletic","Lazy","Slow"};
		for(i=1;i<=n;i++)
		{scanf("%s %s",str,str1);
		 if( strcmp(view[0],str)==0   )
	     s1=s1+5;
         else if( strcmp(view[1],str)==0 )
		 s1=s1+8;
		 else if( strcmp(view[2],str)==0 )
         {s1=s1+10;a++;}
		 else if( strcmp(view[3],str)==0 )
		 s1=s1+15;
		 else if( strcmp(view[4],str)==0 )
		 s1+=20;
		}
     if(n>=10&&a>0) s1+=50;
return (s1);
}

Double click to view unformatted code.


Back to problem 9