技术文章 2024-12-05 string类型使用 string类型使用 在C++中,std::string是标准库中用来表示字符串的一种 类 ** 型。它的底层实现是一个动态数组,它可以存储任意长度的字符串,自动处理内存的分配和释放。对于C++中的std::string类型数据传参,我们需要理解以下几个方面: 1. std::string 不是基本 0
技术文章 2024-12-03 字符串操作 字符串操作 #include<iostream>using namespace std; // 字符串长度函数int strLength(char *s){ int i=0; while(s[i] != '\0'){ i++; } return i;} // 0
技术文章 2024-12-03 堆栈实验代码--约瑟夫环 堆栈实验代码--约瑟夫环 #include<bits/stdc++.h> // 包含所有标准库using namespace std; // 定义节点结构体struct Node{ int number; // 存储节点的数值 int id; // 存储节点的ID(在约瑟 0
技术文章 2024-12-03 堆栈链表复习--停车场 堆栈链表复习--停车场 #include<iostream>#include<string>#include<iomanip>#include <limits> // 引入 numeric_limits 用于清除缓冲区 #include <vector> // 用于队列中存储多个元素 using n 0
技术文章 2024-12-03 堆栈操作复习 堆栈操作复习 #include<iostream>using namespace std; #define max 20 // 顺序栈struct seqStack{ int data[max]; int top;}; // 置空栈seqStack* init_seqStack(){ 0
技术文章 2024-12-03 链表操作复习 链表操作复习 #include<iostream>using namespace std;// 链表的应用typedef struct Node{ int data; Node* next;}*LinkList;// 双向 typedef struct DNode{ int data; 0
技术文章 2024-12-03 顺序表操作 顺序表操作 #include<iostream>using namespace std;#define maxsize 20 typedef struct{ int data[maxsize]; int last;}SeqList; // 顺序表初始化SeqList *init_seqLis 0