How to swap the elements of an array and put them in a column? The user himself enters the number in the array, an indefinite number
Suppose the user has entered 4 numbers, i.e. an array of 4 elements in length
According to the task, the elements should be interchanged, according to this scheme
1 2 3 4
2 3 4 1
3 4 1 2
4 3 2 1
I just can not figure out how to do it. Wrote the code only to the point where you need to enter elements.
public static void main(String[] args) { System.out.println("Введите длину массива: "); Scanner scan = new Scanner(System.in); int size = scan.nextInt(); int [] array = new int[size]; System.out.println("Введите элементы массива: "); for (int i = 0; i < size; i++) array[i] = scan.nextInt(); String one = Arrays.toString(array); } }