Find the maximum value (see the maximum value)

This question requires to read in two integers A and B, and then output the maximum of the two numbers.

Input format:
Input two integers A and B whose absolute value does not exceed 1000 in one line.

Output format:
For each group of input, output the maximum value in one line.

Input sample:
Here is a set of input. For example:
18 -299

Output sample:
The corresponding output is given here. For example:
18

import java.util.Scanner;

public class Main {
    
    
    public static void main(String[] args) {
    
    
        Scanner sc=new Scanner(System.in);
        while (sc.hasNextInt()){
    
    
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a>b?a:b);
        }
    }
}

Guess you like

Origin blog.csdn.net/weixin_51430516/article/details/115048363
Recommended