#include<iostream>
#include<vector>
using namespace std;
int main() {
vector<int>vec = { 1,2,3,4,5,2,2,2,2,2,2,2,2,2,2};
int m = vec.size();
for (auto it = vec.begin(); it != vec.end();) {
if (*it == 2)it=vec.erase(it);
else it++;
}
for (auto i = vec.begin(); i != vec.end(); ++i) {
cout << *i << endl;
}
}
转载于:https://www.cnblogs.com/yiwufang/p/5295954.html