Оба ввода(активный и закомменченный) работали и у меня в предыдущих задачах и у людей в комментариях. В местном компиляторе отказывается сразу же на стадии считывания с клавиатуры. В IntelJ: "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at Test_prac.main(Test_prac.java:22)".
Сортировка трех чисел:
public static void main(String[] args) throws Exception {
// BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
//int a = Integer.parseInt(r.readLine());
//int b = Integer.parseInt(r.readLine());
//int c = Integer.parseInt(r.readLine());
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s1 = reader.readLine();
String s2 = reader.readLine();
String s3 = reader.readLine();
int a = Integer.parseInt(s1);
int b = Integer.parseInt(s2);
int c = Integer.parseInt(s3);
int arr[] = new int[3];
arr[0] = a;
arr[1] = b;
arr[2] = c;
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if(arr[j] > arr[j+1]){
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
System.out.print(arr[0] + arr[1] + arr[2]);
}