View Code of Problem 9

#include <stdio.h>
#include <string.h>

int main(void)
{
    int n,j = 1;
    while(scanf("%d",&n) != EOF)
    {
        getchar();
        char ml[1000][100],str1[100],str2[100];
        int i, index = 0,tsc = 0;
        for(i = 0;i < n;i++)
        {
            scanf("%s%s",str1,str2);
            int k = 0,l;
            for(l= 0;l < strlen(str1);l++)
                ml[i][k++] = str1[l];

            ml[i][k++] = ' ';
            for(l = 0;l < strlen(str2);l++)
                ml[i][k++] = str2[l];
            ml[i][k] = '\0';
            if(strcmp(ml[i],"Athletic goat") == 0)
            {
                index = 1;
                tsc += 10;
            }
            if(strcmp(ml[i],"Pleasant goat") == 0)
            {
                tsc += 5;
            }
            if(strcmp(ml[i],"Pretty goat") == 0)
            {
                tsc += 8;
            }
            if(strcmp(ml[i],"Lazy goat") == 0)
            {
                tsc += 15;
            }
            if(strcmp(ml[i],"Slow goat") == 0)
            {
                tsc += 20;
            }
        }
        if(n >= 10 && index == 1)
            tsc += 50;
        printf("Case #%d: %d\n",j++,tsc);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 9