Question
import java.util.Random; import java.util.Arrays; public class Exercise3_01 { public static void main(String[] args) { Random r = new Random(); int arr[] = new int[200]; for(int
import java.util.Random;
import java.util.Arrays;
public class Exercise3_01
{
public static void main(String[] args)
{
Random r = new Random();
int arr[] = new int[200];
for(int i=0;i { arr[i] = r.nextInt(1000001); } System.out.println("Before sorting"); System.out.println(); for(int i=0;i { System.out.format("%10d",arr[i]); if((i+1)%4==0) { System.out.println(); } } for(int i=0;i { int min = i; for(int j=i+1;j { if(arr[j] { min = j; } } int t = arr[i]; arr[i] = arr[min]; arr[min] = t; } System.out.println(); System.out.println("After sorting Ascending"); System.out.println(); for(int i=0;i { System.out.format("%10d",arr[i]); if((i+1)%4==0) { System.out.println(); } } } } I need to also sort the numbers by descending order how do I implement that.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started