03 2022 档案
摘要:(29条消息) 二叉树DFS/BFS实现(C++)_aFakeProgramer的博客-CSDN博客_c++二叉树bfs
阅读全文
摘要:背包问题:0-1背包、完全背包和多重背包 - fengzw - 博客园 (cnblogs.com) #include<bits/stdc++.h>using namespace std; int v[] = {0,4,2,3};int w[] = {0, 2,1,3 };int n = 3, m =
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int temp = 1; int count1 =0; void cout1(int k, int j) { for (int i = 0; i < k; i++) { cout << i+j; if (i
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int num, sum,sum1=0,count1 =0, r; int a[100]; vector<int>vec; int main() { for (int i = 0; i < 100; i++)
阅读全文
摘要://[[1,0]]表示学1之前要先学0 class Solution { public: bool canFinish(int numCourses, vector<vector<int>>& prerequisites) { vector<int> vec(numCourses);//记录所有顶点
阅读全文
摘要:(38条消息) 图——C++实现_Mind_V的博客-CSDN博客_c++ 图
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; #define swap1(a,b) do{int c=a, a =b, b =c}while(0) //将k为根的子树调整为大根堆 void HeadAdjust(int a[], int k, int le
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; class node { public: int data; node* next; node* prev; }; class stack1 { public: stack1(); void push(node
阅读全文
摘要:数据结构与算法——单链表的实现及原理 - Suozhiyuan - 博客园 (cnblogs.com) C/C++语言实现单链表(带头结点) - 两猿社 - 博客园 (cnblogs.com) 链表(单链表)的基本操作及C语言实现 (biancheng.net) //链接1的方法 #include<
阅读全文
摘要:#include <iostream> using namespace std; int main() { char a; char array[20]={NULL}; cin.get(array,20); cin.get(a); cout<<array<<" "<<(int)a<<endl; re
阅读全文
摘要:#include<iostream>#include<thread>using namespace std; void fun(int a[],int len){ for(int i =1;i<len;i++){ int temp =a[i]; int j = i-1; while(temp<a[j
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int num, count1,count2,sum; int temp = 0,temp1 = 0; int a[100],b[100]; int* p; void fun(int b[]) { for (i
阅读全文
摘要:#include<iostream> #include<vector> #include<string> using namespace std; string str; #define N 8 int j = 0; /* int main() { while (getline(cin, str))
阅读全文
摘要:题目正文编写一个程序输入一个m*n的矩阵存储并输出,并且求出每行的最大值和每行的总和。 要求把每行总和放入每行最大值的位置,如果有多个最大值,取下标值最小的那一个作为最大值。 最后将结果矩阵输出。 输入输入的第一行包括两个整数m和n(1<=m,n<=100),分别代表矩阵的行和列的维数。 接下来的m
阅读全文
摘要:#include<bits/stdc++.h>using namespace std;string Password(string str) { int len = str.size(); int a[4] = {0}; int count = 0; int num = 0;//重复子串对数 for
阅读全文
摘要:#include<iostream> // // Created by jt on 2020/8/22. // #include <vector> #include <queue> using namespace std; class BiNode { public: int data; BiNod
阅读全文
摘要:queue 操作 queue 和 stack 有一些成员函数相似,但在一些情况下,工作方式有些不同: front():返回 queue 中第一个元素的引用。如果 queue 是常量,就返回一个常引用;如果 queue 为空,返回值是未定义的。 back():返回 queue 中最后一个元素的引用。如
阅读全文
摘要:迭代器类别 STL 标准库为每一种标准容器定义了一种迭代器类型,这意味着,不同容器的迭代器也不同,其功能强弱也有所不同。 容器的迭代器的功能强弱,决定了该容器是否支持 STL 中的某种算法。 常用的迭代器按功能强弱分为输入迭代器、输出迭代器、前向迭代器、双向迭代器、随机访问迭代器 5 种。本节主要介
阅读全文
摘要://遍历 vector 容器。 #include <iostream> //需要引入 vector 头文件 #include <vector> using namespace std; int main() { vector<int> v{ 1,2,3,4,5,6,7,8,9,10 }; //v被初
阅读全文
摘要:#include <iostream> using namespace std; #define N 21 struct Node{ int x; int y; }; int dx[4]={-1,1,0,0}; int dy[4]={0,0,-1,1}; char map[N][N]; int vi
阅读全文
摘要:可见,结构体中的变量,可以直接通过"."操作符来访问。 而对于结构体指针而言:必须通过"->"符号来访问指针所指结构体的变量。
阅读全文
摘要:(1)全局数组,也就是定义在main函数外面的数组,元素的默认值是全部为0的 (2)局部数组,定义在函数内部的数组,其值默认是随机的. (37条消息) C语言的未初始化的数组的值为什么是随机的_weixin_33982670的博客-CSDN博客
阅读全文
摘要:HJ16 购物单#include<bits/stdc++.h> using namespace std; int main() { int n = 5,m =10; int w[6] = {0,20,10,10,30,40}; int v[6] = {0,5,2,1,5,7}; int b[n+1]
阅读全文
摘要:重点: 空格符匹配 ' ' 不是'\0' " "表示空格这个符号的首地址这是个指针char x x是字符 //x只能赋值一个字符char *y y是指针 //y可以赋值一串字符string s s是指针 s[0]是字符所以字符匹配可以if(x == s[o])不能(x == s) ‘0’ 0对应的A
阅读全文
摘要:/*使用动态数组来做,输入的字符串依次存入数组中, 最后返回数组中最后一个元素(字符串)的长度*/ #include<iostream> #include<string> #include<vector> using namespace std; int main(){ string input;
阅读全文
摘要:class Student{ private: //私有的 char *m_name; int m_age; float m_score; public: //共有的 void setname(char *name); void setage(int age); void setscore(floa
阅读全文
摘要:《The Art of Unix Programming》 《C++语言的设计和演化》 你读过最好的计算机书籍是哪一本?它主要讲了什么内容,你从中学到哪些有益的收获? - 知乎 (zhihu.com) Nginx完全开发指南:使用C、C++和OpenResty pdf电子书下载-码农书籍网 (man
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int a[150],b[150],c[150],d[150],q,t,p[100]; int main(){ cin>>q; t = q; for(int i=0;q>0;i++,q--){ cin>>a[i
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; float n,m;; int main(){ cin>>n>>m; printf("%.4f",&n/m); }
阅读全文
摘要:C++ length()、size()、sizeof()三者的区别 - 简书 (jianshu.com)
阅读全文
摘要:错误代码: if(a[i]=="G"&&b[i]!="C") return false; 改正后的代码: if(a[i]=='G'&&b[i]!='C') return false; 错误原因:两种不同类型的数据不能做比较,a[i]表示的是一个字符,“C”表示的是一个字符串的首地址,所以应该把“C”
阅读全文
摘要:class D { int a,b; public: D(int i = 0, int j=0):a(i),b(j){ } D(D&p){a = p.a;b=p.a;} void show(){cout<<a<<""<<b<<endl; } }; D f(D p){ D d1(p); return
阅读全文
摘要:博客园小技巧 - Vamei - 博客园 (cnblogs.com) (36条消息) C++基础知识归纳(1)-大厂必备八股文篇_Garen的博客-CSDN博客_c 八股文
阅读全文
摘要:构造函数的作用:建立对象时 对对象的数据成员初始化析构函数的作用:对象生命期结束时回收对象 C++构造函数详解 (biancheng.net) 4、用参数初始化表对数据成员初始化 参数初始化表来实现对数据成员的初始化。这种方法不在函数体内对数据成员初始化,而是在函数首部实现。 用参数初始化表对数据成
阅读全文
摘要:C++拷贝构造函数(复制构造函数)详解 (biancheng.net) (36条消息) 使用拷贝构造函数的理由和作用【整理】_Nodies-CSDN博客_拷贝构造函数作用及用途 C++规定与类同名的函数就是拷贝构造函数 默认拷贝构造函数 在类定义中如果没有提供自己的拷贝构造函数,则C++提供一个默认
阅读全文
摘要:namespace 可用于 创建两个同名但内容不一样的类 namespace space1{ class A{ public: cout<<"A"<,endl; };};namespace space2{ class A{ public: cout<<"B"<,endl; };}; 调用时 spac
阅读全文
摘要:C++异常处理入门(try和catch)_C语言中文网 (biancheng.net) C++ 通过 throw 语句和 try...catch 语句实现对异常的处理。throw 语句的语法如下: throw 表达式; //throw 抛出的异常 由数据类型匹配 后面捕获的catch //一种特殊情
阅读全文
摘要:#include <bits/stdc++.h>using namespace std; int main(){ string str = "asd"; char *ch ="cc11"; cout<<str[1]<<endl; cout<<ch[2]<<endl; cout<<str.size()
阅读全文
摘要:(36条消息) “懒人”的福音 泛型编程_Loving_Forever_的博客-CSDN博客
阅读全文
摘要:char只表示一个字符,若重复赋值,则或者会覆盖前者: char ch='qwqewqe'; cout<<ch<<endl; 输出:e 因为char只有一个字符,后者会覆盖前者。 2、char * src表示字符串char *src="qwqewqe"; cout<<src<<endl;这里的src
阅读全文
摘要:return x==5; //x=5则返回true int reverse(int x){ int ret=0,max=0x7fffffff,min=0; long rs=0; for(;x;rs=rs*10+x%10,x/=10);、// 循环判断 表达式2(循环条件):x为真 表达式3 两个操作
阅读全文
摘要:bool 函数 要return 0 * bool initlist(node*& temp) { temp = new node;if(!temp)if (temp == NULL) return false; temp->next = NULL;return true;} “\n” 和endl 效
阅读全文
摘要:(35条消息) c++ stringstream(老好用了)_jllongbell的博客-CSDN博客_stringstream int 转换成string //stringstream 类 stringstream stream; int a =123; string str; stream<<
阅读全文
摘要:#include <iostream>#include <string>#include <algorithm> using namespace std; void reverseString(string &s){ int i, j; for (i = 0, j = s.size() - 1; i
阅读全文