How does these lines of codes (int the sort method) effect the first req...
don't understand pls help :)
int temp = Integer.MIN_VALUE;
for (int i = 0; i<20; i++){
for (int j = i + 1; i<20; j++){
if (array[i] < array[j]){
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
package com.codegym.task.task07.task0728;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
In decreasing order
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int[] array = new int[20];
for (int i = 0; i < 20; i++) {
array[i] = Integer.parseInt(reader.readLine());
}
sort(array);
for (int x : array) {
System.out.println(x);
}
}
public static void sort(int[] array) {
int temp = Integer.MIN_VALUE;
for (int i = 0; i<20; i++){
for (int j = i + 1; i<20; j++){
if (array[i]<array[j]){
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
//write your code here
}
}