fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int number;
  6. cin >> number;
  7. int *arr = new int[number];
  8. for (int i = 0; i < number; i++)
  9. {
  10. cin >> arr[i];
  11. }
  12. int last = arr[number - 1];
  13. for (int i = number - 1; i >= 0; i--)
  14. {
  15. arr[i] = arr[i - 1];
  16. }
  17. arr[0] = last;
  18. for (int i = 0; i < number; i++)
  19. {
  20. cout << arr[i] << ' ';
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 4388KB
stdin
4
1 2 3 4
stdout
4 1 2 3