View Code of Problem 63

#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

typedef struct{
	char name[20];
	int height;
	int money;
}Stu;

bool cmpH(Stu a,Stu b){
	return a.height<b.height;
}

bool cmpM(Stu a,Stu b){
	return a.money<b.money;
}

int main(){
	int n;
	cin>>n;
	Stu s[n];
	for(int i=0;i<n;i++){
		cin>>s[i].name>>s[i].height>>s[i].money;
	}
	sort(s,s+n,cmpH);
	int h;
	for(int i=0;i<n;i++){
		if(strcmp(s[i].name,"Suxiao")==0){
			h=i;
		}
	}
	sort(s,s+n,cmpM);
	int m;	
	for(int i=0;i<n;i++){
		if(strcmp(s[i].name,"Suxiao")==0){
			m=i;
		}
	}
	if(h>m){
		cout<<"HEIGHT"<<endl;
	}else if(h<m){
		cout<<"MONEY"<<endl;
	}else{
		cout<<"EQ"<<endl;
	}
} 

Double click to view unformatted code.


Back to problem 63