1036 Boys vs Girls (25)(25 分)

#include
#include
#include
using namespace std;
const int maxn = 1e4 + 10;
struct node {
    string name, gender, id;
    int grade;
    bool f;
}F, M, temp;
int main()
{
    F.grade = 0, M.grade = 100, F.f = false, M.f = false;
    int n;
    scanf("%d", &n);
    while (n--)
    {
        cin >> temp.name >> temp.gender >> temp.id >> temp.grade;
        if (temp.gender == "F"&&temp.grade > F.grade)F = temp, F.f = true;
        if (temp.gender == "M"&&temp.grade < M.grade)M = temp, M.f = true;
    }
    if (F.f == false)printf("Absent\n");
    else cout << F.name << " " << F.id << endl;
    if(M.f==false)printf("Absent\n");
    else cout << M.name << " " << M.id << endl;
    if (F.f == false || M.f == false)printf("NA");
    else printf("%d", F.grade - M.grade);
    return 0;
}

你可能感兴趣的:(1036 Boys vs Girls (25)(25 分))