The largest of the three

Give three integers and find the largest of them

public class Solution {
    
    
    public static int maxOfThreeNumbers(int num1, int num2, int num3) {
    
    
               return Math.max(Math.max(num1,num2),num3);
    }
    public static void main(String [] args){
    
    
        int num1=0,num2=0,num3=0;
        Scanner sc = new Scanner(System.in);
        num1 = sc.nextInt();
        num2 = sc.nextInt();
        num3 = sc.nextInt();
        System.out.print("输入:num1="+num1+",num2="+num2+",num3="+num3);
        System.out.print("输出:"+maxOfThreeNumbers(num1,num2,num3));
    }
}

Guess you like

Origin blog.csdn.net/A_Tu_daddy/article/details/103533662