现在的位置: 首页 > 综合 > 正文

remove

2012年09月25日 ⁄ 综合 ⁄ 共 361字 ⁄ 字号 评论关闭
// 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;
}

抱歉!评论已关闭.