优先队列——成绩从高到低排列,相同者按语文成绩排列

这段代码展示了如何使用C++中的优先队列(priority_queue)来实现成绩从高到低排列,当总分相同时,按照语文成绩进行排序。通过定义`student`类,并重载`<`操作符,可以方便地比较学生的分数。在`main`函数中创建并填充优先队列,然后逐个输出队列顶部(即最高分)的学生信息。
摘要由CSDN通过智能技术生成
//
//  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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值