
c++入门
c++的入门
普通网友
这个作者很懒,什么都没留下…
展开
-
Devc++快捷键
代码自动补全 shift+enter。代码对齐 ctrl+shift+a。整体左移 shift+tab。原创 2023-02-14 12:20:10 · 2297 阅读 · 0 评论 -
算法入门规划
下面是算法入门学习的导图原创 2022-03-05 13:07:09 · 217 阅读 · 0 评论 -
算法合集3.13
bfs#include<bits/stdc++.h>using namespace std;int a[100][100],v[100][100];struct point{ int x; int y; int step;};queue<point>r;int dx[4]={0,0,-1,1};int dy[4]={1,-1,0,0};int main(){ int n,m,startx,starty,p,q; scanf("%d%d",&n,原创 2022-03-13 21:40:00 · 309 阅读 · 0 评论 -
C++中sscanf、sprintf与getline
sscanf#include<bits/stdc++.h>using namespace std;void test01(){ char *str="123456abcde"; char buff[1024]={0}; sscanf(str,"%*d%s",buff); printf("buf:%s\n",buff);} void test011(){ char *str="abcde123456"; char buff[1024]={0}; sscanf..转载 2022-04-01 20:21:36 · 271 阅读 · 0 评论 -
stl初识vector容器
#include<bits/stdc++.h>#include<vector>#include<algorithm>using namespace std;void MyPrintf(int val){ cout<<val<<endl;}void test01(){ //创建vector容器对象,并且通过模板参数指定容器中存放的数据类型 vector<int>v; //向容器中放数据 v.push_back.原创 2022-03-06 15:17:13 · 133 阅读 · 2 评论 -
【无标题】
完全二叉树的权值时间限制: 1Sec 内存限制: 128MB题目描述:给定一棵包含 N 个节点的完全二叉树,树上每个节点都有一个权值,按从 上到下、从左到右的顺序依次是 A1, A2, · · · AN,如下图所示:现在小明要把相同深度的节点的权值加在一起,他想知道哪个深度的节点 权值之和最大?如果有多个深度的权值和同为最大,请你输出其中最小的深度。注:根的深度是 1。输入:第一行包含一个整数 N。 第二行包含N个整数A1,A2,··· AN。输出:输出一个整数代表答案。样例输转载 2022-02-28 23:41:33 · 108 阅读 · 0 评论 -
结构体数组与结构体指针
#include<iostream>using namespace std;//1.创建学生数据类型:学生包括(姓名,年龄,分数) #include<string>struct Student{ string name; int age; int score;}s3;int main(){struct Student stuArray[3]={ {"张三",18,100},{"李四",28,99},{"王五",38,66}};//3、给结...原创 2022-02-28 22:29:23 · 344 阅读 · 0 评论 -
C++之结构体
#include<iostream>using namespace std;//1.创建学生数据类型:学生包括(姓名,年龄,分数) #include<string>struct Student{ string name; int age; int score;}s3;int main(){//2.1 struct Student s1struct Student s1;s1.name="张三";s1.age=18;s1.score=10...原创 2022-02-28 22:30:18 · 417 阅读 · 0 评论 -
指针数组函数结合案例
三者结合的冒泡排序法#include<iostream>using namespace std;void bubbleSort(int *arr,int len){ for(int i=0;i<len-1;i++){ for(int j=0;j<len-i;j++){ if(arr[j]>arr[j+1]){ int temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } }原创 2022-02-27 20:55:20 · 86 阅读 · 0 评论 -
指针与函数
指针函数#include<iostream>using namespace std;void swap01(int *p1,int *p2){ int temp=*p1; *p1=*p2; *p2=temp; // // //}int main(){int a=10;int b=20;swap01(&a,&b);//2、地址传递//如果是地址传递,可以修饰实参 cout<<"a= "<<a<<e...原创 2022-02-27 17:25:56 · 132 阅读 · 0 评论 -
指针和数组
#include<iostream>using namespace std;int main(){int arr[10]={1,2,3,4,5,6,7,8,9,10};cout<<"第一个元素为:"<<arr[0]<<endl;int *p=arr;//arr就是数组首地址cout<<"利用指针访问第一个元素: "<<*p<<endl;p++;//让指针向后偏移4个字节cout<<"利用指针访问.原创 2022-02-27 17:11:16 · 89 阅读 · 0 评论 -
const修饰指针
常量指针指针常量const既修饰指针,又修饰常量原创 2022-02-27 16:48:34 · 133 阅读 · 0 评论 -
空指针和野指针
空指针#include<iostream>using namespace std;int main(){//空指针//1、空指针用以给指针变量进行初始化 int *p=NULL;//2、空指针是不能访问的 *p=100是错误的不能访问//0~255之间的内存编号是系统占用的,因此不可以访问 system("pause"); return 0;}野指针#include<iostream>using namespace std;...原创 2022-02-27 16:31:25 · 73 阅读 · 0 评论 -
指针入门及指针内存大小
#include<iostream>using namespace std;int main(){ int a=10; int *p; p=&a; cout<<"a的地址为: "<<&a<<endl; cout<<"指针p为:"<<p<<endl; *p=1000; cout<<"a= "<<a<<endl; cout<<"*p=...原创 2022-02-27 16:12:35 · 880 阅读 · 0 评论 -
函数的常见样式
1.无参无返#include<iostream>using namespace std; void test1(){ cout<<"this is test01"<<endl; } int main(){ test1(); } 2.有参无返#include<iostream>using namespace std; void test2(int a){ cout<<"this is test02="&l原创 2022-02-27 15:10:41 · 154 阅读 · 0 评论 -
利用函数进行交换(c++)
#include<iostream>using namespace std; void swap(int num1,int num2){ cout<<"交换前: "<<endl; cout<<"num1 = "<<num1<<endl; cout<<"num2 "<<num2<<endl; int temp=num1; num1=num2; num2=temp; c.原创 2022-02-27 14:46:42 · 248 阅读 · 0 评论 -
c++循环、continue、排序、goto以及猜数字小游戏
打印*#include<iostream>using namespace std;#include<string.h>int main(){ for(int i=1;i<=9;i++){ for(int j=1;j<i;j++){ cout<<j<<"*"<<i<<"="<<j*i<<" "; } cout<<endl; } system("pau.原创 2022-02-26 19:56:00 · 3690 阅读 · 0 评论 -
c++学习日常
转义字符字符风格#include<iostream>using namespace std;#include<string.h>int main(){ //1.c语言风格 char str[]="hello world"; cout<<str<<endl; //2.c++风格 string str2="hello world"; cout<<str2<<endl; system("pause...原创 2022-02-24 17:17:34 · 177 阅读 · 0 评论 -
c++简单定义
#include<iostream>using namespace std;int main(){ int a=10;cout<<"a="<<a<<endl;system("pause"); return 0;}原创 2022-02-24 00:05:34 · 252 阅读 · 0 评论 -
c++的Hello World
#include<iostream>using namespace std;int main(){cout<<"hello world"<<endl;system("pause"); return 0;}原创 2022-02-23 15:48:37 · 116 阅读 · 2 评论