USER INPUT PRINT ORIGINAL,REVERSE ARRAY AND SORTED ARRAY
package com.cnc;
import java.io.OutputStream;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("How many values do you want?");
int count = sc.nextInt();
int[] array = new int[count];
for (int i = 0; i < count; i++) {
System.out.println("Enter array element " + (i + 1));
array[i] = sc.nextInt();
}
System.out.println("Original element ");
for (int i = 0; i < count; i++) {
System.out.print(array[i] + " ");
}
System.out.println("");
System.out.println("Reversed element ");
for (int i = count - 1; i >= 0; i--) {
System.out.print(array[i] + " ");
}
//////////////// SORTED ARRAY ////////////////////////
System.out.println("");
System.out.println("Arranged element ");
for (int i = 0; i < array.length; i++) {
for (int j = i + 1; j < array.length; j++) {
if (array[i] > array[j]) {
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
}
}