使用指向函数的指针数组 bool cmp1(Stu s1,Stu s2); bool cmp2(Stu s1,Stu s2); //使用指向函数的指针数组 bool (*cmp_ptr[]) (Stu,Stu) = {cmp1,cmp2}; ...
分类:
编程语言 时间:
2019-03-03 20:57:42
阅读次数:
179
#include using namespace std; #define ll long long bool cmp(int a,int b){ return a>b; } int main() { int m,n; scanf("%d %d",&m,&n); int a[m+1]={0}; in... ...
分类:
其他好文 时间:
2019-03-01 12:46:16
阅读次数:
226
普通排序:使用c++的stl工具就可以完成,在头文件中加入algorithm。例如要对数组a[1]~a[n]进行排序,sort(a+1,a+n+1)即可。 下面说一些sort的拓展。sort默认的是升序,要是需要改成降序,可以自己写一个cmp比较函数, 或者也可以在头文件中加入functional, ...
分类:
编程语言 时间:
2019-02-26 19:39:31
阅读次数:
194
一、收获: 1.qsort函数对数组、结构体等进行排序 #include <stdlib.h>//必须用stdlib.h,没用.h不用namespace不行 参数:1待排序数组首地址 2数组中待排序元素数量 3各元素的占用空间大小 4指向函数的指针,用于确定排序的顺序 eg: (1)重写cmp,固定 ...
分类:
其他好文 时间:
2019-02-23 01:30:03
阅读次数:
301
```c++ //BFS划分树的层 vector tree[maxn]; queue q; q.clear(); q.push(root); int cnt = 1; //统计如果队列的点的总数 int cmp = 0; //第cmp个访问的节点 int last = 1; //当前层数的最后一个节 ...
分类:
其他好文 时间:
2019-02-22 12:35:21
阅读次数:
181
1、错误描述 严重: Servlet.service() for servlet [springmvc] in context with path [/cmp] threw exception [Filtered request failed.] with root cause java.io.Op ...
分类:
编程语言 时间:
2019-02-16 13:50:34
阅读次数:
214
cmp的编写 return a>b(从大到小) a<b(从小到大) bool cmp(int a, int b){ return(Node[a].weight>Node[b].weight); } sort(Node[parent].child.begin(),Node[parent].child. ...
分类:
其他好文 时间:
2019-02-09 21:13:12
阅读次数:
235
代码一: //背包问题 #include<iostream> #include<vector> #include<algorithm> using namespace std; struct node{ double w; double p; double t; }; int cmp(const n ...
分类:
其他好文 时间:
2019-02-09 17:42:53
阅读次数:
189
#include<iostream> #include<vector> #include<algorithm> #include<cstring> using namespace std; struct str{ char s[16]; int index; }; bool cmp(str a,st ...
分类:
其他好文 时间:
2019-02-02 19:25:37
阅读次数:
135