1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream> // std::cout
#include <algorithm> // std::remove_if
bool removeVal (int i) { return (i==1 || i==2); }
int main () {
int myints[3][15] = { {0,4,8,9,5,11,10,2,12,7,3,6,1,0,0},
{0,10,11,9,8,5,4,1,7,3,6,12,1,0,0},
{0,0,8,9,5,4,11,10,2,12,7,3,6,1,0} };
// bounds of range:
int* pbegin = myints;
int* pend = myints+sizeof(myints)/sizeof(int);
pend = std::remove_if (pbegin, pend, removeVal);
std::cout << "the range contains:";
for (int* p=pbegin; p!=pend; ++p)
std::cout << ' ' << *p;
std::cout << '\n';
return 0;
}
|