SHARE
TWEET

Untitled

a guest Feb 27th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Test
  5. {
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         System.out.println("Enter array length: ");
  9.         int[] arr = new int[sc.nextInt()];
  10.         int a = 0;
  11.         int b = arr.length - 1;
  12.         System.out.println("Enter nums array: ");
  13.         while (a<arr.length) {
  14.             arr[a] = sc.nextInt();
  15.             a++;
  16.         }
  17.         int c = arr[b];
  18.         a = 0;
  19.         a = b - 1;
  20.         while (b>0) {
  21.             arr[b] = arr[a];
  22.             a--;
  23.             b--;
  24.         }
  25.         arr[0] = c;
  26.         System.out.println(Arrays.toString(arr));
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top