Height Advantage (C++) kkmd66

ideas

Sort, compare ranking positions

Description:

Suxiao is the shortest guy in the class, and this guy is the most edible. So the monthly spending is always the most. He has always had low self-esteem about his height. He was afraid that this would bring great trouble to him in finding a girlfriend in the future. Parents are afraid that he will eat less, so they will give him more money every month. At present, he wants to know whether he has the most advantage in Height or Money in this class. This will help him find the idealistic GF. What does most dominant mean? That is, in which aspect he ranks higher in the class, which aspect is the most advantageous. It seems that the phenomenon of competition in the world has become very serious recently? Please proceed with caution!

Input:

The first line is an integer N, indicating that there are N boys in this class (1<=n<=1000) The following N lines, each line contains three data The first name (string) The second is the height (integer) The third The third is Money (integer), separated by spaces. The first name does not contain spaces and should not exceed 20 characters.

Output:

Please find the most advantageous aspect of Suxiao? If it is the most dominant in height, output: HEIGHT Otherwise, if it is the most recent dominance of Money, output: MONEY If it has the same advantage, output: EQ

Sample Input:

4
Laocheng 175 800
Suxiao 168 850
Caimi 181 650
Langhua 168 900

Sample Output:

MONEY

#include <iostream>
#include "string"
#include "vector"
#include "algorithm"

using namespace std;

/**
 * kkmd66
 * @return
 */

int main() {
    
    

    int n, m_Height, m_Money;
    cin >> n;

    //收集信息
    vector<int> Height;
    vector<int> Money;
    for (int i = 0; i < n; ++i) {
    
    
        string name;
        int height, money;

        cin >> name >> height >> money;

        if (name == "Suxiao") {
    
    
            m_Height = height;
            m_Money = money;
        }

        Height.push_back(height);
        Money.push_back(money);
    }

    //排序
    sort(Height.begin(),Height.end());
    sort(Money.begin(),Money.end());

    //判断哪个优势
    int locate_height,locate_money;

    for (int i = 0; i < Height.size(); ++i) {
    
    
        if (Height[i]==m_Height)
            locate_height=i;
    }

    for (int i = 0; i < Money.size(); ++i) {
    
    
        if (Money[i]==m_Money)
            locate_money=i;

    }

    //输出
    if (locate_money<locate_height)
        cout<<"HEIGHT";
    if (locate_money>locate_height)
        cout<<"MONEY";
    if (locate_height==locate_money)
        cout<<"EQ";

    return 0;

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324187116&siteId=291194637