orz这个我记得我当时写的很崩溃,还是没有完全通过哇的一下就哭了
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
typedef struct node
{
char num[10];
int a_score;
int b_score;
}NODE;
bool cmp(NODE a, NODE b) {
/*if (a.a_score+a.b_score > b.a_score+b.b_score)
return true;
else if (a.a_score + a.b_score == b.a_score + b.b_score)
{
if (a.a_score > b.a_score)
return true;
else if (a.a_score == b.a_score)
return (strcmp(a.num, b.num) > 0) ? false : true;
else if (a.a_score < b.a_score)
return false;
}
else if (a.a_score + a.b_score < b.a_score + b.b_score)
return false;
return false;*/
return a.a_score + a.b_score != b.a_score + b.b_score ? a.a_score + a.b_score > b.a_score + b.b_score :(a.a_score != b.a_score ? a.a_score > b.a_score : a.num < b.num);
}
int main()
{
vector<node>q[4];
int total, low, high;
int count = 0;
cin >> total >> low >> high;
for (int i = 0; i < total; i++)
{
NODE node;
cin >> node.num >> node.a_score >> node.b_score;
if (node.a_score >= low && node.b_score >= low)
{
if (node.a_score >= high && node.b_score >= high)
q[0].push_back(node);
else if (node.a_score >= high && node.b_score < high)
q[1].push_back(node);
else if (node.a_score < high&&node.b_score >= high)
q[2].push_back(node);
else
q[3].push_back(node);
count++;
}
}
cout << count << endl;
for(int i=0;i<4;i++)
{
sort(q[i].begin(), q[i].end(),cmp);
for (int j = 0; j < q[i].size(); j++)
{
cout << q[i][j].num << " " << q[i][j].a_score << " " << q[i][j].b_score << endl;
}
}
system("pause");
return 0;
}