fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int a[n];
  8. for(int i = 0; i < n; i++){
  9. a[i] = i + 1;
  10. }
  11. for(int i = n - 1; i >= 0; i--){
  12. cout << a[i] << " ";
  13. }
  14. return 0;
  15. }
Success #stdin #stdout 0.01s 5276KB
stdin
4 
1 2 3 4
stdout
4 3 2 1