I tried to write a sorting algorythm with the tools already at hand (yes I know there are more simple ways of doing this).
when i let the program run, it does exactly what it should and then ends like its supposed to. But upon validation it just runs and runs and then fails for 'infinite loop'.
Can maybe someone explain to me why that is?
package de.codegym.task.task06.task0622;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
Aufsteigende Zahlen
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int c = Integer.parseInt(reader.readLine());
int d = Integer.parseInt(reader.readLine());
int e = Integer.parseInt(reader.readLine());
int temp;
while (!((a < b) && (b < c) && (c < d) && (d < e))) {
if (a > b) {
temp = a;
a = b;
b = temp;
} else if (b > c) {
temp = b;
b = c;
c = temp;
} else if (c > d) {
temp = c;
c = d;
d = temp;
} else if (d > e) {
temp = d;
d = e;
e = temp;
}
}
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);
}
}