var sc = new Scanner(System.in);
int min = Integer.MAX_VALUE;//8
int min2 = Integer.MAX_VALUE;//9
while(sc.hasNextInt())
{
int x = sc.nextInt();//8 7
min = x < min? x : min;
min2 = x < min2 & x > min ? x:min2;
}
sc.close();
System.out.println(Integer.max(min,min2));
решение же корректно,в чём проблема?
даже если вывести System.out.println(min2); всё равно 2 пункта не проходит...
package com.javarush.task.pro.task04.task0410;
import java.util.Scanner;
/*
Второе минимальное число из введенных
*/
public class Solution {
public static void main(String[] args) {
var sc = new Scanner(System.in);
int min = Integer.MAX_VALUE;//8
int min2 = Integer.MAX_VALUE;//9
while(sc.hasNextInt())
{
int x = sc.nextInt();//8 7
min = x < min? x : min;
min2 = x < min2 & x > min ? x:min2;
}
sc.close();
System.out.println(min2);
}
}