This commit is contained in:
2025-09-15 21:12:04 +08:00
commit 3f58f483ff
144 changed files with 5298 additions and 0 deletions

31
else/demo/1.h Normal file
View File

@@ -0,0 +1,31 @@
//
// Created by 李洋 on 2024/1/8.
//
#ifndef LEECODE_C_1_H
#define LEECODE_C_1_H
#include <iostream>
#include <vector>
#include <stdlib.h>
using namespace std;
void test1() {
//方式一
int a;
cout << "输入长度:";
cin >> a;
int *p = (int *) malloc(a * sizeof(int)); //c写法在运行中分配空间创建指定长度数组
p[a - 1] = 1;
cout << p[a-1] << endl;
//方式2 推荐
vector<int> b; //c++ 向量,可以看作是动态数组,自动扩充容量
vector<vector<int>> c; //二维动态数组
b.push_back(1);
b.push_back(2);
b.size(); //获取当前长度
}
#endif //LEECODE_C_1_H

24
else/demo/2.h Normal file
View File

@@ -0,0 +1,24 @@
//
// Created by 李洋 on 2024/1/11.
//
#ifndef LEECODE_C_2_H
#define LEECODE_C_2_H
#include <iostream>
using namespace std;
void test1(int *p, int index) {
cout << p[index];
}
void run() {
int arr[3];
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
test1(arr, 2);
}
#endif //LEECODE_C_2_H