fork download
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
  9. String[] params1 = bufferedReader.readLine().split(" ");
  10. int number;
  11. number = Integer.parseInt(params1[0]);
  12. int arr[] = new int[number];
  13. String[] params2 = bufferedReader.readLine().split(" ");
  14. for (int i = 0; i < number; i++)
  15. {
  16. arr[i] = Integer.parseInt(params2[i]);
  17. }
  18. int last = arr[number - 1];
  19. for (int i = number - 1; i > 0; i--)
  20. {
  21. arr[i] = arr[i - 1];
  22. }
  23. arr[0] = last;
  24. for (int i = 0; i < number; i++)
  25. {
  26. System.out.print(arr[i]);
  27. System.out.print(' ');
  28. }
  29. }
  30. }
Success #stdin #stdout 0.04s 2184192KB
stdin
5
1 2 3 4 5
stdout
5 1 2 3 4