STL中vector容器实现反转(reverse)
#include "stdafx.h"
#include<iostream>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
int temp;
vector <int> inputVector;
cin>>temp;
while(temp != 0)
{
inputVector.push_back(temp);
cin>>temp;
}
//vector实现反转
vector<int>::reverse_iterator riter;
for(riter=inputVector.rbegin();riter!=inputVector.rend();riter++)
{
cout<<*riter<<" ";
}
return 0;
}