Last active
          August 29, 2015 13:56 
        
      - 
      
- 
        Save pepet96/8969359 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import java.util.Scanner; | |
| public class LeftShift { | |
| public static void main(String [] args) { | |
| Scanner input = new Scanner(System.in); | |
| int a = input.nextInt(); | |
| int [] arr = new int [a]; | |
| for (int i = 0; i < a; i++) { | |
| arr[i] = input.nextInt(); | |
| } | |
| int [] shiftarr = new int [a]; | |
| shiftarr = shift(arr); | |
| for (int j = 0; j < shiftarr.length; j++) { | |
| System.out.println(shiftarr[j] + " "); | |
| } | |
| } | |
| public static int [] shift(int [] arr) { | |
| int [] myArray = new int [arr.length]; | |
| myArray[arr.length-1] = arr[0]; | |
| for (int i = arr.length - 1; i > 0; i--) { | |
| int x = i-1; | |
| myArray[x] = arr[i]; | |
| } | |
| return myArray; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment