#include #include #include #include #include #include using namespace std; //myAlgo_remove_if1.cpp int filter(int); int main() { int n1[10] = { 69 ,75,63,61,65,64,68,64,71,70 }; vectorv1, v2; vector::iterator it; ostream_iterator< int > output( cout, " " ); //push_back for(int i =0; i <=10; i++) {v1.push_back(n1[i]); } cout<<"\n original array \n\t \b "; copy(v1.begin(),v1.end(), output); // v1.push_back(80); cout<<"\n v1.push_back(80) \n\t \b"; copy(v1.begin(),v1.end(), output); make_heap(v1.begin(),v1.end()); cout<<"\nmake heap: largest to front \n\t"; copy(v1.begin(),v1.end(), output); // using remove_copy_if cout<<"\n remove_copy_if filter below 65 from v1 "; cout<<"\n added to v2 \n\t"; v2.resize(10); it = remove_copy_if(v1.begin(),v1.end(),v2.begin(),filter); copy(v2.begin(),it, output); //comparing with remove_if cout<<"\n remove_if filter below 65 from v1 "; cout<<"\n\t"; v2.resize(10); it = remove_if(v1.begin(),v1.end(),filter); copy(v1.begin(),it, output); //---- erase v1.erase(v1.begin(),v1.end()); cout<<"\n erase \n\t"; copy(v1.begin(),v1.end(), output); //---------- return 0; } int filter(int n1) { return n1 >65; }