fork download
  1. #include <vector>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. int main() {
  6. int n;
  7. std::cin >> n;
  8. std::vector<int> arr(n);
  9. for(int& ele: arr) std::cin >> ele;
  10.  
  11. //std::reverse(std::begin(arr), std::end(arr));
  12. //for(const int ele: arr) std::cout << ele << " ";
  13. //or simply
  14. std::for_each(arr.rbegin(), arr.rend(),[](const int ele){ std::cout << ele << " "; });
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 4448KB
stdin
3
1 2 3
stdout
3 2 1