結構體排序

来源:互联网 发布:管家公进销存软件 编辑:程序博客网 时间:2024/06/08 18:05

對結構體排序,下面是對tree這個結構體根據其w的值做升序排序

struct tree{    int u,v,w;}tr[range2];bool cmp(const tree &x,const tree &y)  //cmp是sort要用的排序規則{   return x.w<y.w;}sort(tr,tr+k,cmp);


看到還有用operator<的方法

0 0
原创粉丝点击