当前位置:网站首页>Erase method in string
Erase method in string
2022-07-02 08:00:00 【HBUcs2020】
1.
Put the starting position in the middle
Or starting position and number
#include<iostream>
#include<string>
using namespace std;
int main(){
string str = "hello c++! +++";
// From the position pos=10 Start deleting at , Until the end
// namely : " +++"
str.erase(10);
cout << '-' << str << '-' << endl;
// From the position pos=6 Start at , Delete 4 Characters
// namely : "c++!"
str.erase(6, 4);
cout << '-' << str << '-' << endl;
return 0;
}2.
iterator [ )
#include<iostream>
#include<string>
using namespace std;
int main(){
string str = "hello c++! +++";
// Delete "+++" One space before
str.erase(str.begin()+10);
cout << '-' << str << '-' << endl;
// Delete "+++"
str.erase(str.begin() + 10, str.end());
cout << '-' << str << '-' << endl;
return 0;
}3. Single character of iterator position
iterator erase(const_iterator position)
Delete a single character at the iterator position , And back to Next element The iterator
4.pop_back(): Delete the last element
5. Often with find Functions together
string longer("That's a funny hat.");
//size_type loc1 = longer.find("hat"); // There is
size_type loc1 = longer.find("hello"); // non-existent
if (loc1 == string::npos)
cout<< "not found" <<endl;边栏推荐
- 用于类别增量学习的动态可扩展表征 -- DER
- 【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
- Sorting out dialectics of nature
- How to clean up logs on notebook computers to improve the response speed of web pages
- Go functions make, slice, append
- 【学习笔记】反向误差传播之数值微分
- 【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
- 关于原型图的深入理解
- How gensim freezes some word vectors for incremental training
- It's great to save 10000 pictures of girls
猜你喜欢

Embedding malware into neural networks
![[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video](/img/bc/c54f1f12867dc22592cadd5a43df60.png)
[CVPR‘22 Oral2] TAN: Temporal Alignment Networks for Long-term Video

It's great to save 10000 pictures of girls

【Cutout】《Improved Regularization of Convolutional Neural Networks with Cutout》

Execution of procedures

利用超球嵌入来增强对抗训练

Semi supervised mixpatch

Target detection for long tail distribution -- balanced group softmax

Sorting out dialectics of nature
![[learning notes] matlab self compiled Gaussian smoother +sobel operator derivation](/img/f1/4afde3a4bf01254b3e3ff8bc659f9c.png)
[learning notes] matlab self compiled Gaussian smoother +sobel operator derivation
随机推荐
Feature Engineering: summary of common feature transformation methods
针对tqdm和print的顺序问题
Meta Learning 简述
Organigramme des activités
Label propagation
How gensim freezes some word vectors for incremental training
学习写文章格式
【MagNet】《Progressive Semantic Segmentation》
It's great to save 10000 pictures of girls
【Random Erasing】《Random Erasing Data Augmentation》
How to turn on night mode on laptop
【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》
【MnasNet】《MnasNet:Platform-Aware Neural Architecture Search for Mobile》
【Programming】
[C # note] the data in DataGridView saved in WinForm is excel and CSV
Comparison of chat Chinese corpus (attach links to various resources)
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
[binocular vision] binocular stereo matching
Vscode下中文乱码问题
[learning notes] numerical differentiation of back error propagation