Advertisement
jenrus

Задача №71. Циклический сдвиг вправо

Oct 18th, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class hw2{
  4.     public static void main(String[] args){
  5.         Scanner scan = new Scanner(System.in);
  6.         int b = scan.nextInt();
  7.         int[] a = new int[b];
  8.         int[] c = new int[b];
  9.         for(int i=0; i<a.length; i++){
  10.             a[i]=scan.nextInt();
  11.         }
  12.         System.arraycopy(a, 0, c, 1, b-1);
  13.         System.arraycopy(a, b-1, c, 0, 1);
  14.         for(int i=0; i<c.length; i++){
  15.             System.out.print(c[i]+" ");
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement