public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a, b, min = Integer.MAX_VALUE, anotherMin = Integer.MAX_VALUE;
while (scanner.hasNextInt()) {
a = scanner.nextInt();
min = a < min ? a : min;
if (scanner.hasNextInt()) {
b = scanner.nextInt();
anotherMin = b < anotherMin ? b : anotherMin;
}
}
scanner.close();
min = anotherMin < min ? min : anotherMin;
System.out.println(min);
}
}package com.javarush.task.pro.task04.task0410;
import java.util.Scanner;
/*
Второе минимальное число из введенных
*/
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a, b, min = Integer.MAX_VALUE, anotherMin = Integer.MAX_VALUE;
while (scanner.hasNextInt()) {
a = scanner.nextInt();
min = a < min ? a : min;
if (scanner.hasNextInt()) {
b = scanner.nextInt();
anotherMin = b < anotherMin ? b : anotherMin;
}
}
min = anotherMin < min ? min : anotherMin;
System.out.println(min);
}
}