greatest among three numbers

 

public class Solution {
    public static void main(String[] args) {
        Scanner ip = new Scanner(System.in);
        System.out.print("Enter A: ");
        int a = ip.nextInt();
        System.out.print("Enter B: ");
        int b = ip.nextInt();
        System.out.print("Enter C: ");
        int c = ip.nextInt();
        int great = a >= b ? (a >= c ? a : c) : (b >= c ? b : c);
        System.out.println("Greatest among three numbers is: " + great);
        ip.close();
    }
}



OUTPUT:
Enter A: 1
Enter B: 2
Enter C: 3
Greatest among three numbers is: 3

 

上一篇:OPC


下一篇:python set()、len()、type()、保留小数、EOFError