remove

// remove algorithm example
#include <iostream>
#include
<algorithm>
using namespace std;

int main () {
int myints[] = {10,20,30,30,20,10,10,20}; // 10 20 30 30 20 10 10 20

// bounds of range:
int* pbegin = myints; // ^
int* pend = myints+sizeof(myints)/sizeof(int); // ^ ^

pend
= remove (pbegin, pend, 20); // 10 30 30 10 10 ? ? ?
// ^ ^
cout << "range contains:";
for (int* p=pbegin; p!=pend; ++p)
cout
<< " " << *p;

cout
<< endl;

return 0;
}

posted on 2011-07-29 23:18  more think, more gains  阅读(134)  评论(0编辑  收藏  举报

导航