自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

零界

就让这成为起点

  • 博客(108)
  • 收藏
  • 关注

原创 常见错误总结

#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ //1.使用未初始化指针 int a=1; int *p = NULL; p = &a; printf(" %d\n", *p); //2.将值当地址赋值给指针 int s = 666; int *.

2021-06-12 00:47:02 178

原创 常引用

#include <stdio.h>#include <stdlib.h>//常引用 const修饰符int main(void){ int a = 10; int &b = a; b = 100; printf("a=%d\n", a); //1.用变量初始化常引用 int ai = 10; const int &bi = ai; //bi = 100; //常引用是让变量引用变成只读,不能通过引用对变量进行修 printf("bi.

2021-03-25 01:13:51 185

原创 指针引用

#include <stdio.h>#include <stdlib.h>//二级指针引用void age1(int **l){ static int ling = 16; *l = &ling;}//指针引用void age2(int* &l){ static int ling = 17; l = &ling;}//两者 效果相同 后者逻辑比较简单int main(void){ int x = 666; int *.

2021-03-19 02:27:38 182

原创 引用本质

#include <stdio.h>#include <stdlib.h>// swap1 等同于 swap2int swap1(int &a, int &b){ int t = a; a = b; b = t; return 0;}int swap2(int * const a, int * const b){ int t = *a; *a = *b; *b = t; return 0;}int main(voi.

2021-03-16 01:48:25 134

原创 c++——引用概念

#include <stdio.h>#include <stdlib.h>//使用引用//1 指针交换void love(int *a, int *b){ int tmp; tmp = *a; *a = *b; *b = tmp;}//2. 引用交换 void love1(int &a, int &b){ int tmp; tmp = a; a = b; b = tmp;}int main(void){ int a = 6.

2021-03-13 00:56:38 61

原创 函数指针

#include <stdio.h>#include <stdlib.h>int opam_int(const void *a, const void *b){ //printf("opam_in函数指针的调用。。。。。。。。。。\n"); //强制类型转换 int *ai = (int *)a; int *bi = (int *)b; //printf("ai地址:0x%p bi地址:0x%p\n", &a, &b); return .

2021-01-21 18:58:03 129

原创 void-类型指针

/**12. void 类型指针 void => 空类型 void* => 空类型指针, 只存储地址的值,丢失类型,无法访问,要访问其值, 我们必须对这个指 针做出正确的类型转换,然后再间接引用指针。 所有其它类型的指针都可以隐式自动转换成 void 类型指针, 反之需要强制转换**/#include <stdio.h>#include <stdlib.h>int main(void){ int age[] ={1, 2, 3}; char i.

2021-01-14 00:36:53 222

原创 数组跟指针的区别——传参

/** 项目精讲-“我们不一样“之数组与指针的区别 数组:数组是用于储存多个相同类型数据的集合。 指针:指针是一个变量,但是它和普通变量不一样, 它存放的是其它变量在内存中的地址。 1. 赋值数组:只能一个一个元素的赋值或拷贝 指针:指针变量可以相互赋值 2. 表示范围 数组有效范围就是其空间的范围,数组名使用下表引用元素, 不能指向别的数组 指针可以指向任何地址,但是不能随意访问,必须依附在变量有效范围之内 3. sizeof 数组:数组所占存储空间的内存:sizeof(数组名.

2021-01-09 00:07:08 540

原创 指针和二维数组-使用普通指针访问二维数组

#include <stdlib.h>#include <stdio.h>int main(void){ int A[3][4] ={ {81, 32, 33, 44}, {35, 60, 85, 20}, {16, 53, 45, 555} }; //指针存储值 int *p = NULL; int *you = NULL; //定义指针用于遍历二维数组 you = &A[0][0]; //等同于 you = A[0]; p =.

2021-01-01 00:38:41 794 4

原创 指针和二维数组-指向数组的指针

#include <stdio.h>#include <stdlib.h>int main(void){ int age[4][4]={ {56, 95, 45, 52}, {54, 50, 22, 20}, {15, 32, 82, 25}, {13, 31, 45, 57}, }; int (*p)[4]; //定义一个指向四个成员的数组的指针 int *boy = NULL; p = &age[0]; boy = &(.

2020-12-30 23:23:15 112

原创 存储指针的数组

#include <stdio.h>#include <stdlib.h>int main(void){ int age[3][4] = { {19, 2, 3, 4,}, {5, 6, 7, 8,}, {9, 10, 11, 112} }; //定义一个有两个元素的指针数组,每个元素都是一个指针变量 int *neme[2]; //设置一个数组指针 存储最大的两个值 if(age[0][0] >= age[0][1]){ .

2020-12-10 01:52:19 2932 1

原创 指针与数组的纠缠

#include <stdio.h>#include <stdlib.h>void age1(int age1[], int age11){ int count=NULL; for(count=0; count<age11; count++){ //数组表示法 printf("第%d位元素: %d\n", count+1, age1[count]); //指针表示法 printf("第%d位元素: %d\n\n", count+1, *(age1+c.

2020-12-06 00:26:50 77

原创 多级指针定义使用

```cpp#include <stdio.h>#include <stdlib.h>int main(void){ int age = 666; //普通定义 int *age1 = &age; //一级指针指向变量 int **age2 = &age1;//二级指针指向一级指针 int ***age3 = &age2;//三级指针指向二级指针 int ****age4 = &age3;//四级指针指向三级指针 //**..

2020-12-04 00:46:50 196

原创 二级指针

`#include <stdio.h>#include <stdlib.h>int main(void){int age1 = 15;int *p = &age1;int **p1 = &p;printf("p1=0x%d p=0x%d age1= 0x%d\n", **p1, *p, age1);printf("p1=0x%p p=0x%p age1= 0x%p\n", **p1, *p, age1);int *tmp = *p1;pr.

2020-11-28 01:12:11 160

原创 const-渣男-直男-暖男的区别

//int * age = 16 渣男//int const * age = 16 直男//const int * age = 16 直男//int * const age = 16 暖男 不允许指向别的地址//const int* const = 16 超级暖男 不允许指向别的地址 也不能修改指向地址变量的值#include <stdio.h>#include <stdlib.h>int main(void){ int girl = 2.

2020-11-24 01:32:57 229

原创 指针与指针之间加减运算

#include <stdio.h>#include <stdlib.h>int main(void){ int age[]={1, 2, 33, 44, 55, 6}; int time[]={3, 4, 65, 85, 91, 2}; int len = sizeof(age)/sizeof(age[0]); int *age1 = age+4; int *time1 = age+3; printf("age1-time1=%d\n", age1-time1.

2020-11-22 00:26:33 1296 1

原创 指针与整数之间加减运算

#include <stdio.h>#include <stdlib.h>#include <string.h>int main(void){ int age[] ={11, 12, 15, 65, 82, 22}; int len = sizeof(age) / sizeof(age[0]); //计算数组总数 int *p = NULL; p = age; printf("第三位数字是:%d\n", *(p+2)); printf("第三位数字.

2020-11-22 00:10:59 1463

原创 指针的算术运算--自增自减运算

#include <stdio.h>#include <stdlib.h>int main(void){ int age[] = {1, 2, 3, 4}; int p = sizeof(age)/sizeof(age[0]); //用数组的方式来访问 for(int i=0; i<p; ++i){ printf("%d ", age[i]); } printf("\n"); //打印数组地址 和第一个成员地址 printf("数组地址:0x%.

2020-11-18 23:37:53 422 1

原创 空指针的使用—未初始化的指针,空指针跟坏指针

#include <stdio.h>#include <stdlib.h>int main(void){ int room1 = 666; int room2 = 999; //int *sp=0; 空指针 就是值为零的指针 int *sp = NULL; //指针设置为空 int ap; printf("请输入你的房间号:"); scanf_s("%d", &ap); //指针在未设置为零的情况下 地址可以理解为随机 printf(".

2020-11-16 00:31:16 425

原创 访问指针—访问指针所指向内容

#include <iostream>#include <Windows.h>/**//1.指针的访问int main(void){ int room = 2; int *p1 = &room; int *p2 = p1; //等同于 int *p2 = &room //1.访问(读、写)指针变量本身的值,和其它普通变量的访问方式相同 int *p3; p3 = p1; printf("room地址:%d\n", &room);.

2020-11-15 20:41:48 4710 1

原创 指针的初始化与地址

#include <stdio.h>#include <stdlib.h>int main(void){ int age = 2; //数组直接赋值 //定义两个指针变量指向age int *p1; int *p2; p1 = &age; p2 = &age; printf("age的地址:0x%p\n", &age); printf("p1指针的地址:0x%p\n", &p1); printf("p2指针的地址.

2020-11-14 00:25:51 910

原创 指针的定义

#include <stdio.h>#include <stdlib.h>#include <iostream>using namespace std;int main(void){ int age; //定义了一个整形变量 int *p; //定义了一个整形指针 p = &age; // 变量地址赋值给指针 printf("请输入一个数字:"); scanf_s("%d", p); //指针通过变量赋予的地址 传输给.

2020-11-12 01:22:37 181

原创 为什么使用指针

#include <iostream>#include <windows.h>#include <stdlib.h>#include <time.h> //时间托头文件using namespace std;//1.函数的值传递 无法通过调用函数 来修改函的实参void name_1(int name_blood){ name_blood += 1000;}//2.被调用函数需要提供更多的 “返回值” 给调用函数boo.

2020-11-08 01:53:23 121

原创 项目练习

#include <iostream>#include <fstream> #include <string> #include <windows.h>#include <stdlib.h>using namespace std;#define N 64//假定谷点是一个比邻接点海拔都要低的点。编写一个名为 isValley 的 函数供你的程序调用 。bool isValley(const double geid[N][N],.

2020-11-06 01:20:58 67

原创 防御式编程

#include <assert.h> //断言头文件#include <iostream>#include <Windows.h>using namespace std;int main(void){ int lose; int a=0; cout << "请输入加到一百的数字:"; cin >> lose; assert(lose<100); for(int i=lose; i<=100; ++i){.

2020-11-06 01:12:46 74

原创 打印杨辉三角形

#include <iostream>#include <Windows.h>#include <iomanip>using namespace std;#define N 15int main(void){ int yanghui[N][N]={0}; //数组元素清零 /** for(int i=0; i<N; ++i){ yanghui[i][0]=1; yanghui[i][i]=1; } **/ for(int i.

2020-11-06 01:03:09 94

原创 项目实现

#include <iostream>#include <fstream> #include <string> #include <windows.h>#include <stdlib.h>using namespace std;#define N 64 //判断峰点bool isPeak(const double grid[N][N], int i, int j);int main(void){ int nrows,.

2020-11-06 00:54:53 245

原创 项目精讲-常见错误总结

2020-11-06 00:41:06 64

原创 二维数组作为函数参数

#include <iostream>#include <Windows.h>//版本一 省略函数//二维数组省略一个高维函数 但低维位函数必须定义void printf1(int a1[][3]){ for(int i=0; i<3; ++i){ for(int j=0; j<3; ++j){ printf("%d\t", a1[i...

2020-04-03 18:18:43 2404

原创 更高维度--多维数组

#include <iostream>#include <Windows.h>#include <stdio.h>#include <stdlib.h>int main(void) { int i, j, k=0; int array1[3][3][3]={ //三维数组的定义 {{1, 2, 3}, {4, 5, 6}...

2020-04-03 18:13:28 149

原创 二维数组的存储方式

#include <stdio.h>#include <stdlib.h>#include <iostream>using namespace std;int main(void) { int i=0; int j=0; //赋值 int array1[3][4]= { {1, 2, 3, 4}, {5, 6, 7, 8},...

2020-04-01 14:20:31 2448

原创 二维数组的访问

#include <iostream>#include <Windows.h>using namespace std;//int array1[3][4]; //全局变量会初始化为零int main(void) { //int i=0,j=0; 初始化为零 //int array1[3][4]; 局部变量 元素值不确定 int array1[3...

2020-03-31 15:04:45 481

原创 二维数组的定义与初始化

#include <iostream>#include <Windows.h>#include <stdio.h>int main(void) { int i; int j; //二维数组的定义 //和数组一样 需要先定义再使用 int a1[5]; //一行女兵 //实例: int a2[3][3]; //三行女兵 //定义了一个二...

2020-03-30 17:11:41 2261

原创 用函数实现金字塔打印,打印的层数用参数指定。

//用函数实现金字塔打印. 打印的层数由参数指定./** * *** ***** ******* ********* **///打印定制金字塔#include <iostream>#include <windows.h>using namespace std;void pyramid(int n, char custom) ...

2020-03-24 12:52:25 1316

原创 制作自己的静态库

#include <iostream>#include <Windows.h>#include "第十四节-制作自己的静态库1.h"using namespace std;int main(void) { cout << add(6,8) << endl; system("pause"); return 0;}//第一步 ...

2020-03-24 12:42:08 139

原创 常见错误结

//第11节 项目精讲-常见错误总结//问题1: 在函数体内定义其他函数[错误]int main(void) { int add(int a, int b) { return a+b; } cout << add(1,3); system("pause"); return 0; }//问题2: 函数的返回类型和实际返回值的类型不匹配.[此时发生”强制类型...

2020-03-23 18:55:32 134

原创 多重梦境之递归函数

#include <iostream>#include <Windows.h>using namespace std;int Fibonacci(int n) { //斐波那契数列 if(n==1 || n==2) { return 1; } return Fibonacci(n-1)+Fibonacci(n-2);}void dream(int...

2020-03-23 18:49:40 185

原创 极速调用之内联函数

#include <iostream>#include <Windows.h>using namespace std;inline int call(int a, int b) { //调用 return a+b;}int main(void) { call(36, 54); cout << call(36, 54) <<...

2020-03-23 18:42:52 93

原创 函数的栈空间

#include <iostream>#include <windows.h>using namespace std;void test(void) { //运行时因为栈帧空间溢出,而崩溃 char bug[1200000]; cout << (int)bug[sizeof(bug)-1] << endl;}void ...

2020-03-23 18:35:09 313

原创 同名不同命之函数重载

#include <iostream>#include <Windows.h>using namespace std;int add(int a, int b) { cout << "调用版本一" << endl; return a+b;}int add(int a, int b, int c) { cout <<...

2020-03-23 18:29:49 308

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除