//
// main.cpp
// 160929
//
// Created by liuzhe on 16/9/29.
// Copyright © 2016年 my_code. All rights reserved.
//
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <list>
using namespace std;
//成绩从高到低排列,相同者按语文成绩排列
class student{
int no;
string name;
int chinese;
int math;
public:
student(){}
student(int no,string name,int chinese,int math){
this->no = no;
this->name = name;
this->chinese = chinese;
this->math = math;
}
int getno()const{
return no;
}
string getname()const{
return name;
}
int getchinese()const{
return chinese;
}
int getmath()c
优先队列——成绩从高到低排列,相同者按语文成绩排列
最新推荐文章于 2023-07-01 15:00:00 发布
这段代码展示了如何使用C++中的优先队列(priority_queue)来实现成绩从高到低排列,当总分相同时,按照语文成绩进行排序。通过定义`student`类,并重载`<`操作符,可以方便地比较学生的分数。在`main`函数中创建并填充优先队列,然后逐个输出队列顶部(即最高分)的学生信息。
摘要由CSDN通过智能技术生成