View Code of Problem 63

#include <stdio.h>
#include <string.h>
#include <math.h>
struct stu {
	char name[20];
	int height;
	int money;
};
int main()
{
	int n,i,j,h,m;
	struct stu s[1000];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%s%d%d", s[i].name, &s[i].height, &s[i].money);
		if(strcmp(s[i].name,"Suxiao")==0)
		{
			h = s[i].height;
			m = s[i].money;
		}
	}
	for (i = 0; i < n-1; i++)
	{
		int hmax = i, mmax = i;
		for (j = i + 1; j < n; j++)
		{
			if (s[hmax].height < s[j].height)
				hmax = j;
			if (s[mmax].money < s[j].money)
				mmax = j;
		}
		if (hmax != i)
		{
			int temp = s[hmax].height;
			s[hmax].height = s[i].height;
			s[i].height = temp;
		}
		if (mmax != i)
		{
			int temp = s[mmax].money;
			s[mmax].money = s[i].money;
			s[i].money = temp;
		}
	}
	int flag1 = 0, flag2 = 0;
	for (i = 0; i < n/2; i++)
	{
		if (h == s[i].height)
			flag1 = 1;
		if (m == s[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