Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ remove all elements equal to

#include <iostream>
#include <vector> 
#include <algorithm> 
using namespace std;

int main()
{
  // initalize a vector nums 
  vector<int> nums = {0,0,1,1,1,1,2,3,3};
  // this removes all instances of the value of nums[2] (1) 
  nums.erase(std::remove(nums.begin(), nums.end(), nums[2]), nums.end());
  
  // output: You will see there are no 1s in the list 
  for(auto i : nums)
    cout << i << ' ';
  cout << endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++ linked list iterator 
Cpp :: c++ open webpage 
Cpp :: string erase 
Cpp :: Pseudocode of Dijkstra’s Algorithm in C++ 
Cpp :: c++ multiply char 
Cpp :: c++ little endian or big endian 
Cpp :: initialize 2d vector c++ 
Cpp :: set iterator 
Cpp :: creating node in c++ 
Cpp :: opencv compile c++ 
Cpp :: stoi in c++ 
Cpp :: prime number program c++ 
Cpp :: log base e synthax c++ 
Cpp :: how to extract a folder using python 
Cpp :: pow without math.h 
Cpp :: find first of a grammar 
Cpp :: C++ vector at() method 
Cpp :: stl map remove item 
Cpp :: if in c++ 
Cpp :: heap allocated array in c ++ 
Cpp :: files c++ 
Cpp :: quicksort algorithm 
Cpp :: create a copy of a vector c++ 
Cpp :: codeforces problem 1030A solution 
Cpp :: how to get characters through their ascii value in c++ 
Cpp :: coinPiles 
Cpp :: how to type a vertical stack program c++ 
Cpp :: cpp pass function with input to thread 
Cpp :: argsort c++ 
Cpp :: how to measure cpp code performace 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =