#include
using namespace std;
Int main ()
{
Vector
Vec. Push_back (1);
Vec. Push_back (2);
Vec. Push_back (3);
Vector
For (unsigned I=vec. The size () - 1; I>=0; I -)
Vec1. Push_back (vec [I]);
return 0;
}
CodePudding user response:
# include
#include
using namespace std;
Int main ()
{
VectorVec.
Vec. Push_back (1);
Vec. Push_back (2);
Vec. Push_back (3);
VectorVec1;
For (int I=vec. The size () - 1; I>=0; I -)
Vec1. Push_back (vec [I]);
for(int i=0; I & lt; Vec1. The size (); I++)
Cout & lt;return 0;
}
The output 3, 2, 1
Problem, unsigned integer, into a lot of positive 1-0, dead cycle, the program crash
CodePudding user response:
Upstairs said to, either with an int or use iteratorsCodePudding user response:
int main ()
{
VectorVec.
Vec. Push_back (1);
Vec. Push_back (2);
Vec. Push_back (3);
Reverse (vec) the begin (), vec. The end ());
return 0;
}
Reverse function in the STL algorithms library is used