C++ sort()函数对结构体排序(STL例子)
用写比较函数的方法,注意返回值是bool型#include <iostream>
#include <algorithm>
using namespace std;
struct wupin{
int c;
int w;
double cost;
}wp[20];
//按排列要求写比较函数 此处降序
bool cmp(wupin a,wupin b)
{
retur
原创
2017-04-01 17:37:37 ·
1592 阅读 ·
0 评论