#include <bits/stdc++.h> #define dbg(x) std::cerr << #x << "=" << x << "\n" using i64 = long long; const int N = 105; std::vector<double> f[N]; void output(int n) { for (int i = 1; i <
shared_ptr std::shared_ptr<int> sp1 = new int(); // shared count = 1, weak count = 0 std::shared_ptr<int> sp2(sp1); // shared count = 2, weak count = 0 std::shared_ptr<int> sp3 = sp2; // shared count = 3, weak count = 0
前言 最近在使用MFC,经常遇见CString类型,同时又经常会使用到CString和Char*类型以及std::string类型的相互转换,故写下这篇随笔记录一下。 CString MFC的封装类 其只有一个数据成员m_pszData,其值为字符串首地址,其数据类型为wchar_t*或char*。但是在m_pszData的前面实际还分配了CSrin
用C++写一个简易线程池 什么是线程池? 用一个池子管理线程。线程过多会带来额外开销,线程池维护多个线程,等待监督管理者分配可并发的任务。一方面避免了处理任务时创建线程开销的代价,另一方面避免了线程过度膨胀导致过分调度,保证内核的充分调用。 线程池的优化思路是这样的:我们先在
定义 :一个或几个循环放在另一个循环体内。 案例: 生成实心直角三角形 : 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int i = 1, n = 1,m; 6 cout << "请输入你所需要生成的直角三角形的高" << endl; 7 cin >> m; 8 cout << endl;
use std::any::Any; use core::fmt::Debug; trait ColTrait: std::fmt::Debug{ fn getself<T>(&self)->T; } #[derive(Debug)] struct DataCell<T>{ val:T, } // #[derive(Debug)] struct Col{ title:String, data:Vec<Box<dyn Co
题目链接 这题看上去一脸不可做,对,我看什么题都不可做。。。 然后瞄一眼题解,发现一个小 \(\tt Trick\) : 判定二分图可以先拉出一个生成树,対生成树进行染色然后看相同颜色内有没有连边。 所以现在的第一步是拉出一个生成树。 首先,我们先把题目中要求的交互函数写出来,我用一个 \(\tt
#include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> #include <Poco/StreamCopier.h> #include <Poco/URI.h> #include <fstream> #include <iostream> #include &l
ROS开发(2)ROS创建自定义消息-普通消息 https://www.cnblogs.com/gooutlook/p/16493595.html 1创建环境工程 1创建catkin_gps/src工程文件环境 在catkin_gps路径下编译 catkin_make 自动生成 2 创建项目工程 环境工程catkin_gps/s
#include <bits/stdc++.h> #define dbg(x) std::cerr << #x << "=" << x << "\n" using i64 = long long; const int N = 1e5 + 9; i64 val[N]; int fa[N]; int find(int x){ if(fa[x] == x) return x; int o
-51 33 2 #include <bits/stdc++.h> #define dbg(x) std::cerr << #x << "=" << x << "\n" using i64 = long long; struct node { i64 x, y, w; int id, circle, rank; bool operator>(node b) {
问题描述:报错函数未定义,实际上函数实现在一个动态库中,反复核实.pro文件写的没问题查找原因:1.查看动态库中有没有此函数strings libfasterRCNN.so | grep init #init为报错的函数名_ZN12TensorRT_SDK4initESsi #找到相关的信息2.c++编译后会修改函数签名,用c++filt命令恢复c++filt
#include <algorithm> #include <iostream> using namespace std; class a { public: template<typename T> static void clearData(T& data) { data.clear(); data.shrink_to_fit(); } }; int main() { std::strin
Codeforces Round #808 (Div. 2) 传送门:https://codeforces.com/contest/1708 错过了,第二天vp的,只写出了AB就卡C了,竟然看不出是贪心555 A. Difference Operations 题意:给一个数组,由如下操作,问能不能使得\(a_2\) 到\(a_n\) 全为0 操作是选择一个i,使得\(a_i=a_i-a_{i-1}\) 。 解:显然
void fun1() { std::thread::id tid = std::this_thread::get_id(); printf("ID is %ld\n", *(long*)&tid); } void fun2() { std::thread::id tid = std::this_thread::get_id(); printf("ID is %ld\n", *(long*)&tid); }
今天讲的这两个算法是Bellman-Ford算法和SPFA算法。 Bellman-Ford算法主要适合求有边数限制的最短路,即路径上最多经过k条边的最短路。该算法效率较低,但代码复杂度小。它的原理是连续进行松弛,在每次松弛时把每条边都更新一下。若在 n-1 次松弛后还能更新,则
题目大意 给出 \(n\), \(m\), \(k\),求满足下面条件的字符串 只包含 l 或 r 总长是 \(n\) 最多有 \(k\) 个相同字符连在一起 最长的神之字符串长度为 \(m\) 上面对神之字符串的定义是:字母出现次数都相同的字符串 题解 Subtask 1 既然有 \(k=1\),那么就只有一种构造的方式,使相邻
代码 #include <iostream> #include <cstdio> #include <string> using namespace std; int main() { int a,b; int c; string s; int f=0; cin>>a>>b; c=a+b; s=to_string(c); for(int i=0;i<s.size();i++){ if((s.size()-i)%3==0
思路 把谁是狼人、谁撒谎的所有可能性全部遍历一遍, 代码 #include <iostream> #include <cstdio> #include <cmath> using namespace std; int a[101]; int b[101]; int c[101]; int main() { for(int i=0;i<101;i++){ b[i]=1; } int n; int f=1; cin>>n; for(int
2022.7.17 模拟赛 \(\to link \leftarrow\) 订货 简单题,但为什么 \(1\le n\le 2\times 10^6\) 的数据我 \(n\log n\) 做法会 \(T\) ? 我不理解 模糊匹配 模拟题 国境线 \(std\) 貌似锅了,直接把 \(std\) 交上去了 来自某同学的一句话:\(\color{Green}{\Huge{我跟\ std\ 锅都锅的一样}
#include <bits/stdc++.h> using namespace std; const int N = 5e5 +5; int h[N],ne[N<<1],e[N<<1],fa[N<<1][22],lg[N<<1],dep[N],idx,n,m,s; inline void add(int x,int y){e[++idx] = y,ne[idx] = h[x];h[x] = idx;} void dfs(int u,int
#include<iostream> using namespace std; void solution(int a[], int aLength, int b[], int bLength, int c[], int cLength) { int res[3] = { a[0],b[0],c[0] }; int i = 0, j = 0, k = 0; while (i < aLength && j < bLength &&
1.1 #include <iostream> using namespace std; void foo(char *p) { cout << "char*" << endl; } void foo(int p) { cout << "int" << endl; } int main() { cout << "hello world" <
当你使用使用时,std标准库中的所有标识符都会在前面默认加上std::,比如std::cin,std::cout等等。 如果并没有熟悉std的函数有哪些,可能会在新建变量名时发生冲突,比如下面这种情况 #include "iostream" using namespace std; int max,min; int main() { cout<<max<<min; retu
代码 #include <iostream> #include <cstdio> #include <string> #include <map> using namespace std; int main() { string s; map<char,int> mp; mp['S']=0; mp['t']=0; mp['r']=0; mp['i']=0