堆基本操作实现最大堆
本文导语: 代码如下:/*** 实现最大堆**/ #include #include #include #include #include using namespace std;const int M = 10003; //定义数据节点class dNode{public: string name; int age; double score; dNode():name("no name"), age(0), score(0.0){} dNode(string name, int age, double score):na...
/**
* 实现最大堆
*
*/
#include
#include
#include
#include
#include
using namespace std;
const int M = 10003;
//定义数据节点
class dNode{
public:
string name;
int age;
double score;
dNode():name("no name"), age(0), score(0.0){}
dNode(string name, int age, double score):name(name), age(age), score(score){}
bool operator < (const dNode & d){
return score < d.score;
}
bool operator > (const dNode &d){
return score > d.score;
}
bool operator = (const dNode &d){
name = d.name;age=d.age;score=d.score;
}
bool operator == (const dNode &d){
return name == d.name && age == d.age && score == d.score;
}
void swap(dNode & a, dNode & b){
dNode tmp = a;
a = b;
b = tmp;
}
void show(){
cout