用scanner从键盘输入3个整数,输出最大的值.

来源:互联网 发布:虚拟多点定位软件 编辑:程序博客网 时间:2024/06/06 19:27
import java.util.Scanner;


public class Max {
public static void main(String[] args) {
System.out.println("请输入三个整数:");
Scanner sc = new Scanner(System.in);

int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();


if (a > b) {
          if (a > c) {
             System.out.println("最大的一个数是:" + a);
          } else {
             System.out.println("最大的一个数是:" + c);
          }
      } else {
          if (b > c) {
             System.out.println("最大的一个数是:" + b);
          } else {
             System.out.println("最大的一个数是:" + c);
          }
      }



}


}
1 0