这个题太简单
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
class CA
{
public:
void run();
private:
int n;
struct stu
{
string name;
char gender;
string id;
int grade;
bool operator < (const stu& a) const
{
return grade>a.grade;
}
};
vector<stu> male;
vector<stu> female;
};
void CA::run()
{
cin>>n;
int i;
for(i=0;i<n;i++)
{
stu st;
cin>>st.name>>st.gender>>st.id>>st.grade;
if(st.gender=='M')
male.push_back(st);
if(st.gender=='F')
female.push_back(st);
}
sort(male.begin(),male.end());
sort(female.begin(),female.end());
int flag=-1;
if(female.size()>=1)
printf("%s %s\n",female.begin()->name.c_str(),female.begin()->id.c_str());
else
{
flag=1;
printf("Absent\n");
}
if(male.size()>=1)
{
printf("%s %s\n",(male.end()-1)->name.c_str(),(male.end()-1)->id.c_str());
}
else
{
flag=1;
printf("Absent\n");
}
if(flag==1)
{
cout<<"NA"<<endl;
}
else
{
double dif=female.begin()->grade-(male.end()-1)->grade;
printf("%.0f",dif);
}
}
int main()
{
CA *a=new CA;
a->run();
return 0;
}