1 #include 2 #include 3 #include 4 using namespace std; 5 struct E{ 6 char name[101]; 7 int age; 8 int score; 9 }buf[1000];10 bool cmp...
分类:
其他好文 时间:
2015-05-05 11:53:48
阅读次数:
86
思路:将每个链表的头存在最小堆中,每次取堆首,然后将取出节点的下一个放入堆中中。 1 class cmp{ 2 public: 3 bool operator()(ListNode* l1,ListNode* l2) 4 { 5 return l1->val>l2-...
分类:
其他好文 时间:
2015-05-05 10:29:37
阅读次数:
163
【模板】排序 1 //sort 2 #include 3 bool cmp(const int a,const int b) 4 { 5 return a>b;//降序排列 6 } 7 8 //qsort 9 #include 10 int cmp(const void *x,const ...
分类:
编程语言 时间:
2015-05-03 10:35:35
阅读次数:
116
数学题目。折腾了一天,这种方法不是最好的,不过按照自己的第一直觉的方法AC还是很开心的。#include#include#include#includeusing namespace std;struct abc{ int start, end;}dt[5000000];bool cmp(co...
分类:
其他好文 时间:
2015-05-02 19:26:32
阅读次数:
178
真不知道为啥全是英文题。。。就不能好好的出中文的啊 啊 啊
果然看错了题意
#include
#include
using namespace std;
struct node
{
long long day,end;
}c[100005];
bool cmp(node x,node y)
{
if(x.end<y.end) return true;
if(x.end==y....
分类:
其他好文 时间:
2015-05-02 16:34:33
阅读次数:
121
百度了很多的资料都没有明白qsort 中 cmp 的用处,用Bing 一搜就搜到一篇自认为比其他都解析清楚的文章直接贴出来算了comparPointer to a function that compares two elements.This function is called repeated...
分类:
其他好文 时间:
2015-05-01 07:01:56
阅读次数:
129
分析:简单贪心题,注意这里给出的已经是单价了,而不是物品的总价值,直接用来排序即可。
#include
#include
using namespace std;
struct A
{
int p,m;
}a[105];
bool cmp(A a1,A a2)
{
return a1.p<a2.p;
}
int main()
{
int v,n,i;
int sum;
whil...
分类:
其他好文 时间:
2015-04-30 21:54:50
阅读次数:
249
分析:最长子序列的变种;另外长方体可以有三种放法,三种放法都存在同一个数组里面,因为每种长方体可以有无限个。
#include
#include
using namespace std;
struct BOX
{
int x,y,z;
} box[100];
int dp[100];
bool cmp(BOX a,BOX b)
{
if(a.x>b.x) return true;
e...
分类:
其他好文 时间:
2015-04-30 14:24:20
阅读次数:
131
题目要求按字典序排列,而且可能有重边所以一开始就将数组从大到小排列,那么我将字符串加入链表时就会令小的不断前移,大的被挤到后面这里有一点问题就是我一开始使用的是qsort:int cmp(const void *s1 , const void *s2){ return strcmp((char*)s...
分类:
其他好文 时间:
2015-04-30 12:05:42
阅读次数:
125
#include
#include
#include
using namespace std;
struct node
{
char name[90],place[90];
int num;
}c[105];
bool cmp(node x,node y)
{
if(strcmp(x.place,y.place)<0) return true;
if(strcmp(x.place,...
分类:
编程语言 时间:
2015-04-30 10:39:46
阅读次数:
162