题目链接 (与PAT B1015
同题)
题目分析
解题思路
按照题意对结构体排序,重写sort()
函数中比较规则cmp
即可,只是分类情况稍微有点麻烦而已。
AC程序(C++)1
/**************************
//@Author: 3stone
//@ACM: PAT. A1062 Talent and Virtue
//@Time: 2018/1/25
//@IDE: VS2017
***************************/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<set>
using namespace std;
//要用scanf/printf,用cin/cout会超时
int low, high;
typedef struct student{
int moral, talent;
string ID;
}Stu;