算法总结之C++基础与STL
作者:
闲闲
,
2020-10-14 15:54:05
,
所有人可见
,
阅读 725
字符串的相关操作
初始化
char str1[] = {"Le Chapon Dodu"};
string str2 = {"Le Chapon Dodu"};
char str3[20] = "jinan";
赋值,拼接和附加
char charr1[20];
char charr2[20] = "jinan";
//赋值操作
charr1 = charr2;
string str2 = {"Le Chapon Dodu"};
string str3 = {"Le Dodu"};
str3 = str3 + str2;
结构体
//申请结构体
stuct tree
{
int l;
int r;
double k;
}
//申请结构体数组
struct tree a[50];
//初始化结构体
tree b = {1,2,1.0};
a[0] = b;
vector
#include<vector>
vector<int> v;
//把1压入堆栈
v.push_back(1);
//返回首尾元素
int a = v.begain();
int b = v.end();
//返回v的大小
v.size();
//判断是否为空
v.empty();