fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. ios::sync_with_stdio(false);
  7. cin.tie(0);
  8.  
  9. int n;
  10.  
  11. while (cin>>n) {
  12. if (n == 0)
  13. break;
  14.  
  15. int arr[n];
  16. for (int i = 0; i < n; ++i) {
  17. cin >> arr[i];
  18. }
  19.  
  20. for (int i = n - 1; i >= 0; i--) {
  21. cout << arr[i] << '\n';
  22. }
  23.  
  24. cout << "0\n";
  25. }
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5308KB
stdin
5
3
4
2
5
1
2
1
2
0
stdout
1
5
2
4
3
0
2
1
0