Horje
how to delete an element in vector pair in cpp Code Example
how to delete an element in vector pair in cpp
#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;
}




Cpp

Related
c++ function of find maximum value in an array Code Example c++ function of find maximum value in an array Code Example
How to turn an integer variable into a char c++ Code Example How to turn an integer variable into a char c++ Code Example
cmake g++ address sanitizer Code Example cmake g++ address sanitizer Code Example
what is the default include path in ubuntu c++ Code Example what is the default include path in ubuntu c++ Code Example
hello world in c/++ Code Example hello world in c/++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10