向量的删除
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> array;
array.push_back(1);
array.push_back(6);
array.push_back(3);
array.push_back(6);
array.push_back(6);
array.push_back(2);
vector<int>::iterator itor;
for (itor = array.begin(); itor != array.end();)
{
if (6 == *itor)
{
itor = array.erase(itor);
continue;
}
itor++;
}
itor = array.begin();
cout << "arrary.size = " << array.size() << endl;
for (itor = array.begin(); itor != array.end();)
{
cout << (*itor);
itor++;
}
system("pause");
return 0;
}
/*
输出:
arrary.size = 3
132
*/