Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner in = new Scanner(System.in);
  9.         System.out.println("Size:");
  10.         int size = in.nextInt();
  11.  
  12.         int [] mass = new int[size];
  13.  
  14.         int i;
  15.         for ( i=0;i<size;i++)
  16.         {
  17.             System.out.println("Element:");
  18.             mass[i] = in.nextInt();
  19.         }
  20.         System.out.println("Count rol:");
  21.         int rol_count = in.nextInt();
  22.  
  23.         System.out.println("Before:");
  24.         for (i=0;i<size;i++)
  25.         {
  26.             System.out.print( mass[i]+" ");
  27.         }
  28.         System.out.println("");
  29.         int buf;
  30.  
  31.         for(int j=0; j<rol_count;j++)
  32.         {
  33.             buf = mass[0];
  34.  
  35.             for (i=1;i<size;i++)
  36.             {
  37.              mass[i-1]= mass[i];
  38.             }
  39.  
  40.             mass[size-1]=buf;
  41.         }
  42.  
  43.         System.out.println("After:");
  44.         for (i=0;i<size;i++)
  45.         {
  46.            System.out.print( mass[i]+" ");
  47.         }
  48.  
  49.  
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement