#include <iostream>
#include <algorithm>
using namespace std;
struct student{
int ID;
int Age;
int Score;
};
student stu [3] = {
{1, 18, 88},
{2, 19, 90},
{3, 20, 70}
};
bool comparator(const student &a, const student &b)
{
return (a.Score < b.Score);
}
int main()
{
sort(stu, stu + 3, comparator);
for(int i = 0; i < 3; i++)
cout << stu[i].ID << ' ' << stu[i].Age << ' ' << stu[i].Score << endl;
system("pause");
return 0;
}
C++比较器的实现_函数
最新推荐文章于 2024-02-05 21:46:21 发布