View Code of Problem 9

#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,sum,k=0,j=0;
    string goat;
    while(scanf("%d",&n)!=EOF)
    {
        sum=0;
        for(i=0;i<n;i++)
        {
            cin>>goat;
        	if(goat=="Pleasant goat")
            	sum+=5;
        	if(goat=="Pretty goat")
            	sum+=8;
        	if(goat=="Athletic goat"){
            	sum+=10;
            		k++;
				}
        	if(goat=="Lazy goat")
            	sum+=15;
        	if(goat=="Slow goat")
            	sum+=20;
        	cin>>goat;
        }
        if((n>=10)&&k>0)
        {
              sum+=50;
        }
        j++;
        printf("Case #%d: %d\n",j,sum);
    }
    return 0;
}
/*
Main.cc: In function 'int main()':
Main.cc:6:5: error: 'string' was not declared in this scope
     string goat;
     ^
Main.cc:12:13: error: 'cin' was not declared in this scope
             cin>>goat;
             ^
Main.cc:12:18: error: 'goat' was not declared in this scope
             cin>>goat;
                  ^
*/

Double click to view unformatted code.


Back to problem 9