随笔分类 - C/C++
摘要://判断邻接矩阵是否有环 bool judge(vector<vector<int>> path,int n){ bool index = 0; while(1){ index = 1; for(int i=0;i<n;i++){ int sum = 0; for(int j=0;j<n;j++){
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int n = 1005; vector<int> father = vector<int>(n,0); //初始化 void init(){ for(int i=0;i<father.size();i++){
阅读全文
摘要:前置工作 引入#include<fstream>才可以使用输入输出流 读文件 #include<fstream> #include<iostream> using namespace std; int main(){ char data[100]; //读取 ifstream fin; fin.op
阅读全文
摘要:map unordered_map 添加元素 unordered_map<int,int> map; map[i]++; 遍历 for(auto &t : map){ cout<<t.first<<t.second<<endl; } 把统计的出来的出现频率(即map中的value)排个序 有的同学可
阅读全文
摘要:暴力 不用多说,肯定是超时的,时间复杂度达到了O(n^4) class Solution { public: int fourSumCount(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3, vector<int>& nums4
阅读全文
摘要:题目 给定一棵二叉树,你需要计算它的直径长度。一棵二叉树的直径长度是任意两个结点路径长度中的最大值。这条路径可能穿过也可能不穿过根结点。 注意:两结点之间的路径长度是以它们之间边的数目表示。 输入输出 input:[1,2,3,4,5] output:3 input:[4,-7,-3,null,nu
阅读全文
摘要:JAVA_TOOL_OPTIONS; -agentpath:"D:\工具\C++转流程图\JDK等4个文件\CppSourceFlowchart__for_windows_linux_macOS\sjt_windows_x64.dll"
阅读全文
摘要:https://blog.csdn.net/qq_43722079/article/details/107690205
阅读全文
摘要:https://www.cnblogs.com/arxive/p/11669034.html
阅读全文
摘要:位运算符 |符号|含义| |-|-| |&|按位与| |||按位或| |^|按位异或| |~|取反| |<<|左移| |>>|右移| 运算规则 与运算 “a&b”是指将参加运算的两个整数a和b,按二进制位进行“与”运算。 运算规则:0&0=0; 0&1=0; 1&0=0; 1&1=1; 即:两位同时
阅读全文
摘要:什么是unordered_map unordered_map 容器,直译过来就是"无序 map 容器"的意思。所谓“无序”,指的是 unordered_map 容器不会像 map 容器那样对存储的数据进行排序。换句话说,unordered_map 容器和 map 容器仅有一点不同,即 map 容器中
阅读全文
摘要:例题-全排列 给定一个不含重复数字的数组 nums ,返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。 题解 class Solution { public: void dfs(vector<int> nums,vector<int>& allnum,vector<vector<int>>
阅读全文
摘要:C语言中 auto被解释为一个自动存储变量的关键字,也就是申明一块临时的变量内存。 例如: auto a = 3.7; 表示a为一个自动存储的临时变量。 C++语言中 C++ 98标准/C++03标准 同C语言的意思完全一样:auto被解释为一个自动存储变量的关键字,也就是申明一块临时的变量内存。
阅读全文
摘要:push_back() push_back()方法要调用构造函数和复制构造函数,这也就代表着要先构造一个临时对象,然后把临时的copy构造函数拷贝或者移动到容器最后面。 emplace_back() emplace_back()是c++11的新特性。 emplace_back()在实现时,则是直接在
阅读全文
摘要:解决VS2019 自动代码补全功能问题 显示没有提示补全信息 使用快捷键 Ctrl+J 完美解决
阅读全文
摘要:unordered_map介绍 unordered_map记录元素的hash值,根据hash值判断元素是否相同。map相当于java中的TreeMap,unordered_map相当于HashMap。无论从查找、插入上来说,unordered_map的效率都优于hash_map,更优于map;而空间
阅读全文
摘要:1.数字转换为字符串 方法一(利用<sstream>的stringstream,可以是浮点数) #include <iostream> #include <sstream> using namespace std; int main() { double x; string str; strings
阅读全文