结构体

struct data
{
    int xuhao,w;
}node[maxn];

bool cmp(data a,data b) 
{
    return a.dis < b.dis;
}//°´dis´ÓСµ½´óÅÅÐò
View Code
sort(node+1,node+1+n,cmp);
View Code

结构体排序


 

struct data
{
    int price,number;
}a[maxn];
bool cmp(data a,data b)
{
    if(a.price==b.price)return a.number<b.number;
    else return a.price<b.price;
}
//原理:若a<b返回1 ab就换位 
View Code

 

posted @ 2016-08-31 12:37  pandaB  阅读(89)  评论(0编辑  收藏  举报