Advertisement
kirill_76rus

reversed_vector

Sep 11th, 2019
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4. void reversed(vector <int>& temp){
  5. vector <int> tmp;
  6. for(int i=temp.size();i>0;--i){
  7.     tmp.push_back(temp[i-1]);
  8. }
  9.     temp=tmp;
  10. }
  11. int main(){
  12.     int q;
  13.     cin>>q;
  14.     vector <int> nums(q);
  15.     for(auto& i:nums){
  16.         cin>>i;
  17.     }
  18.     reversed(nums);
  19.     for(auto s:nums){
  20.         cout<<s<<' ';
  21.     }
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement