结构体排序-c++

2015-01-26 23:13:31 · 作者: · 浏览: 4

功能是先拍a,若a相等则在其基础上对b进行排序。

用的algorithm中sort进行的排序。

#include
  
   
#include
   
     #include
    
      using namespace std; struct test{ int a; int b; test():a(0),b(0){} test(int x,int y=0):a(x),b(y){} set(int x,int y){a=x;b=y;} }; bool cmp(const test &x,const test &y) { if(x.a != y.a) return x.a