
C++
文章平均质量分 55
C++
buptwhq
这个作者很懒,什么都没留下…
展开
-
【练习题】数据离散化+二维前缀和
保证100%的数据中,点的数量n原创 2022-12-12 01:08:56 · 568 阅读 · 0 评论 -
【LeetCode】306c:根据模式串构造最小数字
给你下标从 0 开始、长度为 n 的字符串 pattern ,它包含两种字符,‘I’ 表示 上升 ,‘D’ 表示 下降。如果 pattern[i] == ‘I’ ,那么 num[i] < num[i + 1]。如果 pattern[i] == ‘D’ ,那么 num[i] > num[i + 1]。由数据范围知,答案字符串长度最多为9,长度为9的字符串根据全排列可知共有。num 包含数字 ‘1’ 到 ‘9’ ,其中每个数字 至多 使用一次。函数来求解某一个排列的下一个排列(根据字典序)。...原创 2022-08-14 23:17:57 · 541 阅读 · 0 评论 -
sort自定义排序方式
2022.05.14sort()方式1:结构体内重载运算符方式2:cmp参数与优先队列类比Java和python的处理方式Javapythonsort()sort(a.begin(), a.end()); sort(a, a + n); // n为数组长度通常用于数组排序,排序方式为按照元素大小从小到大排序当元素为结构体/pair等类型时,以及需要从大到小排序时,需要自定义。方式1:结构体内重载运算符对于结构体:结构体按照某成员值,从小到大排序:需要在结构体内重载运算符,从小到大重载<原创 2022-05-14 18:12:39 · 3050 阅读 · 1 评论 -
常用库函数
2022.05.14reverseuniqueeraserandom_shuffle#include <algorithm>reverse适用于vector或数组#include <iostream>#include <algorithm>#include <vector>using namespace std;const int N = 1010;int main(){ // vector vector<int> c原创 2022-05-14 17:40:55 · 266 阅读 · 0 评论 -
常用STL
2022.05.14vectorqueuemapbitsetpairvector#include <iostream>#include <vector>using namespace std;int main(){ vector<int> whq = {1, 2, 3}; cout << whq[1] << endl; // 2 支持随机访问 whq.push_back(4); cout << whq.size(原创 2022-05-14 17:17:58 · 150 阅读 · 0 评论 -
链表基础(C++)
2022.05.14链表的遍历添加结点链表删除链表空节点链表的遍历#include <iostream>#include <string.h>using namespace std;const int N = 1010;struct Node{ int val; Node* next; Node(int _val):val(_val), next(NULL){} };int main(){// Node node = Node(1);//原创 2022-05-14 16:00:47 · 280 阅读 · 0 评论 -
指针与引用
2022.05.13取地址指针数组与指针指针运算引用取地址#include <iostream>using namespace std;char a, b;string aa;int main(){ char c, d; cout << (void*)&c << endl; cout << (void*)&d << endl; cout << (void*)&a << en原创 2022-05-13 20:30:08 · 301 阅读 · 0 评论 -
类与结构体简单记录
2022.05.13类结构体test类#include <iostream>using namespace std;class Person{ private: // 只能在类里调用 无private的话对于成员变量,class默认是private,结构体默认为public int age, height; double money; string books[100]; public: // 可在外部调用 string name;原创 2022-05-13 18:13:51 · 153 阅读 · 0 评论