c++ 结构体的排序

版权声明:转发请标明原著 https://blog.csdn.net/weixin_39460667/article/details/82695190

引入头文件 

#include<algorithm>

结构体

bool compare(const node &x, const node &y) {
	return x.v > y.v;
}

当用 大于号就是从大到小排序

用小于号就是从小到大排序

sort 函数   

sort(branch+1,branch+m+1,compare);


 

猜你喜欢

转载自blog.csdn.net/weixin_39460667/article/details/82695190