mercredi 17 février 2021

How to rectify error I am facing in make_pair input?

    vector<pair<int,int>>a(n);
    for(int i=0;i<n;i++)
    {
         cin>>t;
          
         a.push_back(make_pair(t,0));
         cout<<a[i].first<<" "<<a[i].second<<endl;
     }

This piece of code that I wrote is giving a wrong output. No matter what input I give, this case it was an array {3,2 5,1 4} I am getting this output.

0 0
0 0
0 0
0 0
0 0

Please help.

Aucun commentaire:

Enregistrer un commentaire