树的建立与层次遍历 #include <iostream>#include <stack>#include <queue>#include <vector>using namespace std;typedef struct TreeNode{ int val; struct TreeNode *left; struct TreeN...
腾讯1_最小公倍数 #include <iostream>using namespace std;int calnum(int a,int b)//求完后再 res = (x*y)/calnum(x,y) ;res即为所求{ while(a!=b) { if(a>b) a=a-b; else ...
升级版链表反转 #include <iostream>using namespace std;typedef struct ListNode{ int val; struct ListNode *next; ListNode(int x):val(x),next(NULL){};}ListNode;void printlist(ListNode *p){ ...
字符串中寻找最长重复字符串和长度 #include <iostream>#include <string>#include <vector>#include <algorithm>using namespace std;int callargeststring(string str1,string str2){ int i=0; for(;i<s...
数组平衡点 #include <iostream>#include <vector>#include <algorithm>using namespace std;int FindBalancePoint(vector<int> &vec){ int leftsum = 0; int rightsum = 0; fo...
虚函数表 记录学习 #include <iostream>using namespace std;class Base {private: virtual void f() { cout << "Base::f" << endl; } virtual void gf() { cout << "Base::gf" << endl; }
两个字符串最长公共子串 string find string find3(string a,string b){ if(a.size()>b.size()) swap(a,b); //确保前面的一个字符串短; string str_m; for(int i=0; i<a.size(); i++) { for(int j=i; j<a.size();...
全志 软件开发笔试 violate 关键字及其作用场景volatile提醒编译器它后面所定义的变量随时都有可能改变,因此编译后的程序每次需要存储或读取这个变量的时候,都会直接从变量地址中读取数据。如果没有volatile关键字,则编译器可能优化读取和存储,可能暂时使用寄存器中的值,如果这个变量由别的程序更新了的话,将出现不一致的现象。中断服务程序中修改的供其它程序检测的变量需要加volatile;多任务环...
C++单例模式 懒汉-双检索 #include <iostream>#include <mutex>using namespace std;class SingleIton{public: static mutex mtx;//静态成员变量类内声明,类外定义 static SingleIton *GetInstance() { if (Instance == NULL)//第...
String 寻找ab出现次数 #include <string>#include <iostream>using namespace std;int main(){ string str = "fabcdabxxabxxxcxab"; int len = str.length(); //寻找ab出现的次数 int index = 0;//ab出现的位置 int cnt = 0;/...
string 操作2 string的比较int compare(const string &s) const; //与字符串s比较int compare(const char *s) const; //与字符串s比较compare函数在>时返回 1,<时返回 -1,==时返回 0。比较区分大小写,比较时参考字典顺序,排越前面的越小。大写的A比小写的a小。10string的子串s...
string 基本操作1 1、string转化为字符数组(3种)string s="abcd";char *a=new char;① strcpy(a,s.c_str()); ② strncpy(a, str.c_str(), 10); //复制s的前10个字符给字符数组a③ int length=s.copy(a,3); a[length]=’\0’; //复制s的前3个字符给字符数组a④ i...
字符串转double,double转字符串各种操作 #include <iostream>#include <sstream>#include <string>#include <vector>#include <iomanip>using namespace std;int main(){ /* stringstream ss; string a...
多线程打印ABC 单线程打印ABC#include <vector>#include <thread>#include <iostream>#include <mutex>using namespace std;mutex sLock;int i = 0;void test(){ sLock.lock(); for (int j = ...
http/https 协议 面试传送门 https://www.cnblogs.com/sunny-sl/p/6529830.htmlhttps://blog.csdn.net/wfh6732/article/details/60878148
DP自学 #include <iostream>#include <algorithm>using namespace std;int main(){ //寻找连续最长子序列 int a[10] ={-2,1,-3,4,-1,5,3,-10,-8,1}; int dp[10]; dp[0] = -2; for(int i=1 ; i...
Windows---内存管理 https://blog.csdn.net/haiross/article/details/46998057虚拟内存页文件是存在硬盘上的系统文件,它的大小可以在系统属性里面设置,它相当于物理内存,所以称为虚拟内存。事实上,它的大小是影响系统快慢的关键所在,如果物理内存不多的情况下。每页的大小和上述所说内存分配的最小单位是一样的,通常是4K或8K进程地址空间的地址是虚拟地址,也就是说,当...
gcb算法(辗转相除法)求最大公约数 int gcb(int a,int b)//辗转相除法 迭代{ while(a%b){ int tmp = a; a = b; b = tmp%b; } return b;}int gcb(int a,int b)//递归{ return a%b==0? b:gcb(b,a%b);}int gcb(...