码迷,mamicode.com
首页 >  
搜索关键字:cmp    ( 878个结果
sort与qsort
一、sort二、qsort头文件:stdlib.h1.int#include#include#includeusing namespace std;int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;//升序}int...
分类:其他好文   时间:2015-08-13 14:23:16    阅读次数:128
Hdu oj 1233 还是畅通工程
分析:Kruskal算法思想:按照边的权值的顺序从小到大查看一遍,如果不产生环(重边也算在内),就把当前这条边加入到生成树中。 #include #include using namespace std; int per[110]; int n; struct stu { int u,v,w; }edge[10000]; int cmp(stu x,stu y) { r...
分类:其他好文   时间:2015-08-11 12:18:07    阅读次数:102
(笔试题)把一个整数数组中重复的数字去掉
题目:把一个整数数组中重复的数字去掉,并输出剩下的不重复的元素。(要求不能开辟新空间)思路:先排序,然后遍历数组比较,详见代码代码:#include #include using namespace std;int cmp(const void* a,const void* b){ retur...
分类:编程语言   时间:2015-08-09 22:17:48    阅读次数:161
寻找数列中第k大的数算法分析
问题描述:给定一系列数{a1,a2,...,an},这些数无序的,现在求第k大的数。看到这个问题,首先想到的是先排序,然后直接输出第k大的数,于是得到啦基于排序的算法算法一:#include#includeusing namespace std;bool cmp(int a, int b){ re....
分类:编程语言   时间:2015-08-09 07:04:15    阅读次数:215
贪心FB
hdu 2037 今年暑假不AC定义结构体,排序,然后贪心。#include#include#includeusing namespace std;struct T{ int s,e;};T program[105];int cmp(struct T a,struct T b){ if...
分类:其他好文   时间:2015-08-08 19:47:44    阅读次数:128
bzoj-3809 Gty的二逼妹子序列
题意: 给出一个长度为n的数列,每个数字在[1,n]内; m次询问,查询[l,r]区间中值在[a,b]中的数字种类数; n 内存限制为28M 题解: 出题人实在太丧病系列; 莫队算法+树状数组这个比较显然吧; 码了一发交上去MLE了,砍了砍内存的常数,还是MLE; 然后发现询问里不能记录左端点所在块。。。在cmp里现求是吗。。。 改完T了!加完读入优化还是T! 没...
分类:其他好文   时间:2015-08-06 15:08:07    阅读次数:95
POJ 1564--Sum It Up【DFS】
#include #include #include #include using namespace std; int n, m, flag; int a[11000], b[11000]; int cmp(int a, int b){ return a > b; } void dfs(int pos , int ans, int sum){ if(sum == n){ fl...
分类:其他好文   时间:2015-08-05 10:36:46    阅读次数:102
心急的C小加
?? #include #include #include using namespace std; typedef struct {     int length;     int weight; }stick; bool cmp(stick x,stick y) {     if(x.length         return true;     if(x...
分类:其他好文   时间:2015-08-04 13:38:34    阅读次数:103
hdu5003
看仔细题意 #include using namespace std; bool cmp(int a,int b) { return a>b; } int main() { int cases; scanf("%d",&cases); while(cases--){ int n,a[500 + 5]; scanf("%d",&n...
分类:其他好文   时间:2015-08-04 09:29:06    阅读次数:125
Python内置函数sorted()以及list.sort()
sorted >>>?help(sorted) Help?on?built-in?function?sorted?in?module?__builtin__: sorted(...) ????sorted(iterable,?cmp=None,?key=None,?reverse=False)?-->?new?sorted?list list.sor...
分类:编程语言   时间:2015-08-02 16:57:06    阅读次数:216
878条   上一页 1 ... 51 52 53 54 55 ... 88 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!