#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void print( vector<int> );
int main()
{
vector<int> vectorObject(5);
print( vectorObject );
vector<int>::iterator p = vectorObject.begin();
cout << *p << endl;
vectorObject.insert( vectorObject.begin(), 1 );
print( vectorObject );
cout << *p << endl;
p = vectorObject.begin();
cout << *p << endl;
vectorObject.erase( vectorObject.begin() );
print( vectorObject );
vectorObject.insert( vectorObject.begin() + 1, 1 );
print( vectorObject );
vectorObject.erase( vectorObject.begin() + 2 );
print( vectorObject );
vectorObject.insert( vectorObject.end(), 3 );
print( vectorObject );
vectorObject.erase( vectorObject.end() - 1 );
print( vectorObject );
vectorObject.insert( vectorObject.begin() + 3, 1 );
print( vectorObject );
vectorObject.erase( find( vectorObject.begin(), vectorObject.end(), 6 ) );
print( vectorObject );
vectorObject.insert( vectorObject.begin() + 1, 3 );
vectorObject.insert( vectorObject.begin() + 5, 3 );
print( vectorObject );
vectorObject.erase( find( vectorObject.begin(), vectorObject.end(), 3 ) );
vectorObject.erase( find( vectorObject.begin(), vectorObject.end(), 3 ) );
print( vectorObject );
vectorObject[0] = 231;
vectorObject[1] = 21;
vectorObject[2] = 116;
vectorObject[3] = 45;
vectorObject[4] = 116;
print( vectorObject );
sort( vectorObject.begin(), vectorObject.end() );
print( vectorObject );
return 0;
}
void print( vector<int> v ) {
vector<int>::iterator p = v.begin();
while ( p != v.end() )
cout << *p++ << " ";
cout << endl;
}
|