fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N;
  6. cin >> N;
  7.  
  8. vector<int> gerbong(N);
  9. for(int i = 0; i < N; i++) {
  10. cin >> gerbong[i];
  11. }
  12.  
  13. for(int i = N - 1; i >= 0; i--) {
  14. cout << gerbong[i];
  15. if(i != 0) {
  16. cout << ",";
  17. }
  18. }
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5300KB
stdin
5
1 2 3 4 5
stdout
5,4,3,2,1