Java入门程序:求两个数中的最大值

版权声明:本文为博主原创文章,仅供学习交流使用,未经博主允许不得转载。 https://blog.csdn.net/qq_43252519/article/details/84065047

Java入门程序:求两个数中的最大值

package test;

import java.util.Scanner;

public class max {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		System.out.println("请依次输入两个整数:a,b(以空格隔开)");
		/*比较两个数的大小*/
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int max;
		if(a >= b){
			max = a;
		}else {
			max = b;
		}
		System.out.println("最大值为:"+max);
	}
	
}

猜你喜欢

转载自blog.csdn.net/qq_43252519/article/details/84065047
今日推荐