Home > Back-end >  The vector array delete specified element so why not
The vector array delete specified element so why not

Time:11-28

#include
using namespace std;
Vector Mp;
Int main ()
{
Mp. The push_back (1);
Mp. The push_back (2);
Mp. The push_back (3);
For (vector : : iterator it=mp. The begin (); it!=mp. The begin (); It++) {
If (* it==2) {
Mp. Erase (it);
break;
}
}
for(int i=0; icout}

return 0;
}

CodePudding user response:

The conditions in the for loop; it!=mp. The begin () should be changed; it!=mp. The end ()

CodePudding user response:

For (vector : : iterator it=mp. The begin (); it!=mp. end (); It++)

CodePudding user response:

The effect well thank you
  • Related