View Code of Problem 63

#include <stdio.h>
#include <string.h>
struct student
{
	char name[100];
	int height;
	int money;
};
int main()
{
	int N,i,j;
	int height=0, money=0;
	struct student stu[1000];
	scanf("%d", &N);
	for (i = 0; i < N; i++)
		scanf("%s%d%d", stu[i].name, &stu[i].height, &stu[i].money);
	for (i = 0; i < N; i++)
		if (strcmp(stu[i].name, "Suxiao"))
		{
			height = stu[i].height;
			money = stu[i].money;
		}
	for (i = 0; i < N-1; i++)
	{
		for (j = i + 1; j < N; j++)
		{
			if (stu[j].height > stu[i].height)
			{
				int temp = stu[i].height;
				stu[i].height = stu[j].height;
				stu[j].height = temp;
			}
			if(stu[j].money>stu[i].money)
			{
				int temp = stu[i].money;
				stu[i].money = stu[j].money;
				stu[j].money = temp;
			}
		}
	}
	int flag1 = 0,flag2=0;
	for (i = 0; i < N / 2; i++)
	{
		if (height == stu[i].height)
			flag1 = 1;
		if (money == stu[i].money)
			flag2 = 1;
	}
	if (flag1 == 1 && flag2 == 0)
		printf("HEIGHT\n");
	else if (flag1 == 0 && flag2 == 1)
		printf("MONEY\n");
	else
		printf("EQ\n");
	return 0;
}

Double click to view unformatted code.


Back to problem 63