View Code of Problem 63

#include <stdio.h>
#include <string.h>
typedef struct node{
    char name[30];
    int money,height;
}person;

int main(void)
{
    person ps[1000];
    int n,i,j,msum = 0,hsum = 0;
    while(scanf("%d",&n) != EOF)
    {
        for(i = 0;i < n;i++)
        {
            scanf("%s%d%d",ps[i].name,&ps[i].height,&ps[i].money);
            msum += ps[i].money;
            hsum += ps[i].height;
            if(!strcmp(ps[i].name,"Suxiao"))
                j = i;
        }
        double am = 1.0 * ps[j].money / msum;
        double ah = 1.0 * ps[j].height / hsum;
        if(am > ah)
            printf("MONEY\n");
        else if(am < ah)
            printf("HEIGHT\n");
        else
            printf("EQ\n");
    }
    return 0;

}

Double click to view unformatted code.


Back to problem 63