我将结构体 $result$ 存入在一个vector ${vResult}$ 中,最近需要在C++中按照结构体中的 $score$ 进行排序,在网上查找了一些资料,这里对采用的方法记录一下,方便以后使用。 一、引入头文件 #include <algorithm> 二、定义排序方法 struct re ...
分类:
编程语言 时间:
2020-05-05 12:23:03
阅读次数:
63
struct cdev *cdev_alloc(void) { struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL); if (p) { INIT_LIST_HEAD(&p->list); kobject_init(&p->kobj, & ...
分类:
其他好文 时间:
2020-05-05 01:03:40
阅读次数:
92
自调整表:所有的插入操作都发生在表的前端。 find操作:当一个元素由find访问的时候,该元素就被移到表的前端,而其他元素的相对顺序保持不变。 以下展示自调整表的数组实现和链表实现。 数组实现: #include <iostream> template <typename Object> clas ...
分类:
其他好文 时间:
2020-05-04 19:39:03
阅读次数:
151
#include "stdafx.h" #include <iostream> #include <string> #include <map> #include <list> #include <queue> #include <stack> typedef struct forest { std ...
分类:
其他好文 时间:
2020-05-04 19:35:37
阅读次数:
47
[Toc] 所有的构造函数都是构造函数Function的实例(允许该构造函数直接通过constructor属性访问构造函数Function) 所有的原型对象都可以近似看成构造函数Object的实例(不允许该原型对象直接通过constructor属性访问构造函数Object) 示例: 判断构造函数、实 ...
分类:
Web程序 时间:
2020-05-04 19:06:36
阅读次数:
59
给定一个二叉树,判断它是否是高度平衡的二叉树。 本题中,一棵高度平衡二叉树定义为: 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1。 来源:力扣(LeetCode) 解法一:记录树高度 /** * Definition for a binary tree node. * struct T ...
分类:
其他好文 时间:
2020-05-04 17:24:08
阅读次数:
52
1 #include <iostream> 2 using namespace std; 3 typedef struct node 4 { 5 int id; 6 struct node* next; 7 }*L; 8 int main() 9 { 10 L l1=NULL, l2=NULL, l ...
分类:
其他好文 时间:
2020-05-04 17:22:17
阅读次数:
81
//网络流s const int INF = 0x3f3f3f3f, maxn = 210; struct E { int u, v, flow; E(int u = 0, int v = 0, int flow = 0): u(u), v(v), flow(flow) {} } edg[maxn ...
分类:
其他好文 时间:
2020-05-04 00:40:18
阅读次数:
49
link class Solution { public: struct Comp{ bool operator()(vector<int>& v1, vector<int>& v2){ return v1[0]+v1[1]>v2[0]+v2[1]; } }; int kthSmallest(vec ...
分类:
其他好文 时间:
2020-05-03 20:13:29
阅读次数:
92
近期在学习Linux C编程,在使用 localtime() 函数时遇到了比较奇怪的问题,我本想对比文件的最近修改时间和系统当前时间年份是否一致,按说定义两个struct tm*类型指针,再获取到两个struct tm *类型的指针变量后进行比较便可,但是无奈这两个结构体指向的tm_year成员值是 ...
分类:
编程语言 时间:
2020-05-03 18:33:56
阅读次数:
97