how to delete an element in vector pair in cpp
C++
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int main()
{
vector< pair<int, int> > v;
int N = 5;
const int threshold = 2;
for(int i = 0; i < N; ++i)
v.push_back(make_pair(i, i));
int i = 0;
while(i < v.size())
if (v[i].second > threshold)
v.erase(v.begin() + i);
else
i++;
for(int i = 0; i < v.size(); ++i)
cout << "(" << v[i].first << ", " << v[i].second << ")\n";
cout << "Done" << endl;
}
Also in C++:
- Title
- c++ compare char array
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- c++ get ascii value of char
- Category
- C++
- Title
- ue4 c++ overlapping functions cpp setup
- Category
- C++
- Title
- insert elements in array in c++11
- Category
- C++
- Title
- range of int
- Category
- C++
- Title
- minimum swaps to sort an array
- Category
- C++
- Title
- how do for loops on c++
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- C++ remove element from set
- Category
- C++
- Title
- length of string c++
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- opperanf >> c++
- Category
- C++
- Title
- c++ excel blank cells
- Category
- C++
- Title
- c++ iterate through constant list
- Category
- C++
- Title
- type id c++
- Category
- C++
- Title
- checking an int in c++
- Category
- C++
- Title
- c++ class template
- Category
- C++
- Title
- c++ program for addition of two numbers using functions
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- How to read a file in in C++
- Category
- C++
- Title
- binary tree search
- Category
- C++
- Title
- loop c++
- Category
- C++
- Title
- c++ passing two dimensional array to function
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- c++ remove text file
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- c++ find prime numbers
- Category
- C++
- Title
- map insert c++
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- c++ function to find minimum element in array
- Category
- C++
- Title
- empty string c++ value
- Category
- C++
- Title
- clear console c++
- Category
- C++
- Title
- select elements from array C++
- Category
- C++
- Title
- c++ give options
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- leveling system c++
- Category
- C++
- Title
- pop from between string c++
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- how to show c++ binary files in sublime text
- Category
- C++
- Title
- min heap priority queue c++
- Category
- C++
- Title
- built in function in c++ for binary to decimal
- Category
- C++
- Title
- pionter in c++
- Category
- C++
- Title
- error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(s[i] != "b"){
- Category
- C++
- Title
- how to delete something in an array c++
- Category
- C++
- Title
- create copy of range of string c++
- Category
- C++
- Title
- how to format decimal palces in c++
- Category
- C++
- Title
- kruskal's algorithm c++ hackerearth
- Category
- C++
- Title
- console colors in C++
- Category
- C++
- Title
- findung the mode in c++
- Category
- C++
- Title
- c++ program to find gcd of 3 numbers
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- first fit algorithm
- Category
- C++
- Title
- how to concatinate two strings in c++
- Category
- C++
- Title
- if vector contains value c++
- Category
- C++
- Title
- how to sort vector in c++
- Category
- C++
- Title
- least number of coins to form a sum
- Category
- C++
- Title
- how to read and write in a file c++
- Category
- C++
- Title
- nan c++ example
- Category
- C++
- Title
- c++ constructor
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- how to find the size of a character array in c++
- Category
- C++
- Title
- 2d vector
- Category
- C++
- Title
- c++ how to skip the last element of vector
- Category
- C++
- Title
- c++ read file line by line
- Category
- C++
- Title
- euler's totient function c++
- Category
- C++
- Title
- array search c++
- Category
- C++
- Title
- private and public in namespace cpp
- Category
- C++
- Title
- maximum possible number atmost k swaps
- Category
- C++
- Title
- accept the noun and the output of plural c++
- Category
- C++
- Title
- how to append one vector to another c++
- Category
- C++
- Title
- change int to string cpp
- Category
- C++
- Title
- function template
- Category
- C++
- Title
- error: invalid conversion from 'Node*' to 'int'
- Category
- C++
- Title
- c++ overload operator
- Category
- C++
- Title
- ceil in c++
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- minmax_element c++
- Category
- C++
- Title
- lisy stl C++
- Category
- C++
- Title
- RLE Encoding/Compression c++
- Category
- C++
- Title
- sorting of array in c++
- Category
- C++
- Title
- c++ vector add element
- Category
- C++
- Title
- c++ not greater than
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- set mimetype validation in mongoose
- Category
- C++
- Title
- calling by reference c++
- Category
- C++
- Title
- qt make widget ignore mouse events
- Category
- C++
- Title
- c++ class constructor
- Category
- C++
- Title
- How to find the kth smallest number in cinstant space
- Category
- C++
- Title
- iterar un map c++
- Category
- C++
- Title
- binary search in set c++
- Category
- C++
- Title
- initialize map c++
- Category
- C++
- Title
- how to remove maximum number of characters in c++ cin,ignore
- Category
- C++
- Title
- how to make string get spaces c++
- Category
- C++
- Title
- stl sort in c++
- Category
- C++
- Title
- double pointers C++
- Category
- C++
- Title
- c++ declare variable
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- compare values within within a vector c++
- Category
- C++