📜  c++ 如果大于 n,则从向量中删除数字 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:45.779000             🧑  作者: Mango

代码示例1
#include 
#include 
#include 
#include 
using namespace std;

int main()
{
  // intitalize both the vector and the target value to be under
  vector V = {2,3,5,11};
  int target = 8;
  
  // remove any numbers in the vector that is larger than the target
  vector :: iterator it = remove_if(V.begin(), V.end(), bind2nd(greater(), target));
  V.erase (it, V.end());
  
  // output the answer
  copy(V.begin(), V.end(), ostream_iterator(cout, " "));
}