java 求两个数最大值
Posted F
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 求两个数最大值相关的知识,希望对你有一定的参考价值。
//find greatest among two numbers import java.util.Scanner; public class Numbers { public static void main(String[] args) { int num1, num2; Scanner ip = new Scanner(System.in); System.out.print("Enter num1: "); num1 = ip.nextInt(); System.out.print("Enter num2: "); num2 = ip.nextInt(); if (num1 > num2) System.out.println(num1 + " is greater that " + num2); else if (num2 > num1) System.out.println(num2 + " is greater that " + num1); else System.out.println("Both are same"); ip.close(); } } OUTPUT: Enter num1: 35 Enter num2: 45 45 is greater that 35
以上是关于java 求两个数最大值的主要内容,如果未能解决你的问题,请参考以下文章