0

I am trying to delete a vector list from another vector list but the program stops responding as soon as I reach the specific part of the program.Here is the program:

#include<iostream>
#include<vector>
#include<iterator>
int main(){
    using namespace std;
    vector<int> a(5);
    int ints[3] = {2,3,5};
    vector<int> b(ints,ints+3);
    for(int i=0; i<5; i++){
        a[i] = i+1;
    }
    vector<int> :: iterator pra;
    vector<int> :: iterator prb;
    cout << "initial list:";
    for(pra = a.begin(); pra!=a.end(); pra++){
        cout << *pra << " ";
    }
    cout << endl;
    for(pra = a.begin(); pra!=a.end(); pra++){
        for(prb = b.begin(); prb!=b.end(); prb++){
            if(*pra == *prb){
                cout << *pra << " ";
                a.erase(pra);
                b.erase(prb);
                break;
            }
        }
    }

    cout << " Final List:"; 
    for(pra = a.begin(); pra!=a.end(); pra++ ){
        cout << *pra << " ";
    }

}
Ahmad Khan
  • 2,655
  • 19
  • 25
Sid
  • 1
  • 2

0 Answers0