struct node  
{  
    int l;  
    int w;  
    bool visited;  
};

int cmp( const int &a, const int &b ){ //单关键字, 降序排序
    if( a > b )
       return 1;
    else
       return 0;
}

bool cmp(const node &a, const node &b)//双关键字 ,先按l升序排序,如果l相同,则按w升序排序。

   
if(a.l!=b.l) 
    { 
       
return a.l<b.l; 
    } 
   
else 
    { 
       
return a.w<b.w; 
    } 

sort(wood, wood
+n, cmp); 

 

 

相关文章:

  • 2022-03-10
猜你喜欢
  • 2021-09-10
  • 2021-10-13
  • 2021-11-01
  • 2021-06-18
  • 2021-07-24
相关资源
相似解决方案