09 2023 档案

摘要:创建Thread:std::thread worker(操作); 打印当前线程的id:std::this_thread::get_id(); is_finished=false; DoWork(){ using namespace std::literals::chrono_literals; st 阅读全文
posted @ 2023-09-26 19:23 iu本u 阅读(72) 评论(0) 推荐(0) 编辑
摘要:回溯算法可以当作是二叉树的结构进行分析,看在叶节点的位置是什么条件收获结果 每个抛进去的结果都是到叶子节点的路径 以leetcode17为例: 每一层遍历的是每一个号码对应的字符串,当号码全部遍历完成就可以返回结果,所以终止条件是(index==string.length());index是层数,s 阅读全文
posted @ 2023-09-26 17:02 iu本u 阅读(14) 评论(0) 推荐(0) 编辑
摘要:lambdas形式是: [](参数列表){操作} 【】里面是捕捉方式,即传参的方式 可以结合lambdas来增加筛选条件 vector<int>v{3,9,7,3,1}; auto it=std::find_if(v.begin(),v.end(),[](int value){return valu 阅读全文
posted @ 2023-09-25 19:21 iu本u 阅读(10) 评论(0) 推荐(0) 编辑
摘要:函数指针可以将函数作为函数的参数,对函数的参数设置想要的操作 void PrintValue(int value){ std::cout<<value<<std::endl; } void ForEarch(const std::vector<int>& v,void(*funtion)(int)) 阅读全文
posted @ 2023-09-20 20:57 iu本u 阅读(4) 评论(0) 推荐(0) 编辑
摘要:#define LOG(x) std::cout<<"Hello"<<std::endl; 在项目属性的c++->Preprocesser(预处理)->Preprocesser Define中添加DR_MODULE,将configuration模式调为release #ifdef DR_MODULE 阅读全文
posted @ 2023-09-20 17:06 iu本u 阅读(69) 评论(0) 推荐(0) 编辑
摘要:元组tuple;#include<tuple> std::tuple<std::string,istd::string,nt>sources; std::get<0>sources,std::get<1>sources; pair std::pair<std::string,std::string> 阅读全文
posted @ 2023-09-20 15:43 iu本u 阅读(5) 评论(0) 推荐(0) 编辑
摘要:时间复杂度为O(n) //维护这个堆 void heapify(vector<int>& nums,int n,int i){ int largest=i;//假设为父节点 int lson=i*2+1; int rson=i*2+2; //找到最大值 if(lson<n&&nums[lson]>n 阅读全文
posted @ 2023-09-19 15:49 iu本u 阅读(8) 评论(0) 推荐(0) 编辑
摘要:分析: 它是有n个节点,n-1条边 所以两个节点连接的边只有一条,那么要么是可以从这条边的起点开始能够到达0,要么是不能,不会有回路的情况 对于数据结构使用哈希表值为vector容器 int bfs(vector<vector<int>>& connections){ unordered_map<i 阅读全文
posted @ 2023-09-15 14:56 iu本u 阅读(6) 评论(0) 推荐(0) 编辑
摘要:是在运行时将文件连接进项目 将dll.lib文件复制至Debug的可执行文件里面;将linker中的input额外依赖改成这个dll.lib文件的名字 阅读全文
posted @ 2023-09-13 20:06 iu本u 阅读(12) 评论(0) 推荐(0) 编辑
摘要:静态连接发生再编译时 第一步要下载相应依赖的文件夹(GLFW) 将依赖的头文件库(include)和图书馆(lib-vcxxx)复制粘贴至项目所在的依赖文件夹位置; Dependencies文件夹创建在项目的解决方案同一级 更改项目属性 在c++的general中的additional includ 阅读全文
posted @ 2023-09-13 20:03 iu本u 阅读(6) 评论(0) 推荐(0) 编辑
摘要:深度优先搜索 vector<bool>vis; int num=0; void dfs(vector<vector<int>>& isConnected,int x){ vis[x]=true; for(int i=0;i<isConnected[x].size();i++){ if(!vis[i] 阅读全文
posted @ 2023-09-13 12:47 iu本u 阅读(3) 评论(0) 推荐(0) 编辑
摘要:模板函数在编译时才创建,开始时并不会创建 类型做模板的参数 #include<iostream> #include<vector> #include<string> template<typename T> void Print(T value){ std::cout<<value<<std::en 阅读全文
posted @ 2023-09-12 19:02 iu本u 阅读(9) 评论(0) 推荐(0) 编辑
摘要:这样会使用复制构造函数6次;push_back()是往后推,会复制一份 struct Vectex{ float x,y,z; Vectex(float x,float y,float z) :x(x),y(y),z(z) {} Vectex(const Vectex& Vectex) :x(Vec 阅读全文
posted @ 2023-09-12 18:15 iu本u 阅读(12) 评论(0) 推荐(0) 编辑
摘要:使用深度优先遍历构造的图,只要访问过就标记已访问 int num=0; vector<bool>vis; void dfs(vector<vector<int>>& rooms,int x){ vis[x]=true; num++; for(auto& v:rooms[x]){ if(!vis[v] 阅读全文
posted @ 2023-09-12 13:49 iu本u 阅读(4) 评论(0) 推荐(0) 编辑
摘要:删除的二叉树节点分4种情况: 叶子节点,直接删除就行 左节点不为空,右节点为空;直接将左子树返回 左节点为空,右节点不为空;直接将右子树返回 左节点和右节点不为空;将右子树最小的节点作为根节点,返回右子树 TreeNode* deleteNode(TreeNode* root, int key) { 阅读全文
posted @ 2023-09-12 13:09 iu本u 阅读(3) 评论(0) 推荐(0) 编辑
摘要:智能指针中de-> class Entity{ public: int x; public: void Print(){ std::cout<<"Hello Entity!"<<std::endl; } }; class scopedPtr{ private: Enity* m_Entity; pu 阅读全文
posted @ 2023-09-07 14:56 iu本u 阅读(4) 评论(0) 推荐(0) 编辑
摘要:使用智能指针删除堆上分配的内存,而不用delete class Entity{ public: int x; public: void Print(){ std::cout<<"Hello Entity!"<<std::endl; } }; class scopedPtr{ private: Eni 阅读全文
posted @ 2023-09-07 14:52 iu本u 阅读(4) 评论(0) 推荐(0) 编辑
摘要:class String{ private: char* m_Buffer; unsigned int m_Size; public: String(const char* string){//首先const char* 等同于string m_Size=int(strlen(string));// 阅读全文
posted @ 2023-09-05 16:49 iu本u 阅读(7) 评论(0) 推荐(0) 编辑
摘要:唯一指针不能复制,它的参数不能使用new关键字创建。 std::unique_ptr<Entity>entity=std::make_unique<Entity>(); std::unique_ptr<Entity>e0=entity; 共享指针有一个引用计数,当计数为0就宣布释放内存。 { std 阅读全文
posted @ 2023-09-05 15:52 iu本u 阅读(17) 评论(0) 推荐(0) 编辑
摘要:dfs lass Solution { public: unordered_map<int,vector<int>>m; void dfs(TreeNode* root,int depth){ if(!root)return; int res=0; depth++; dfs(root->left,d 阅读全文
posted @ 2023-09-05 15:02 iu本u 阅读(10) 评论(0) 推荐(0) 编辑
摘要:前序遍历:中左右(先遍历左子树);中右左(先遍历右子树) 中序遍历:左中右; 后序遍历:左右中; 本题递归: vector<int>v;//记录最先遍历到的右子树 void dfs(TreeNode* root,int depth){ if(!root)return ; if(v.size()==d 阅读全文
posted @ 2023-09-04 16:34 iu本u 阅读(4) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示