C++
常用容器
string
- 定义
string str="ZhangWenYuan";
- 遍历
for(int i=0; i<str.size(); i++){
char c=str[i];
string s(1,c);
}
- 位置索引
str = str + s;
str.push_back(s);
str.insert(pos, s);
string sub_str = str.substr(pos, len);
str.pop_back();
str.erase(pos, len);
str.replace(pos, len, str);
string str = to_string(32);
int num = stoi(str);
float num = stof(str);
double num = stod(str);
char c = str.back();
pos=str.find_first_of('c');
pos=str.find_last_of('c');
size_t found = str.find(str2);
if (found!=std::string::npos)
cout<<found<<endl;
vector
- 定义
vector<int