编写Java程序,输入3个整数,输出其中的最大值

来源:百度知道 编辑:UC知道 时间:2024/05/23 22:57:04

public class T{
public static void main(String args[]){
int a,b,c;
a=args[0];
b=args[1];
c=args[2];
System.out.println("最大值是:"+max{a,b,c});

}
}

import java.util.Scanner;

public class T {
public static void main(String[] args) {
try {
Scanner s = new Scanner(System.in);
System.out.print("输入第一个值(然后回车):");
int one = s.nextInt();
System.out.print("输入第二个值(然后回车):");
int two = s.nextInt();
System.out.print("输入第三个值(然后回车):");
int three = s.nextInt();

int show =0;
if (one < two) {
show = two;
}else{
show = one;
}
if(show < three){
show = three;
}
System.out.println("最大值是 :"+show);

} catch (Exception e) {
System.out.println("---------------请输入合法数字");
}
}
}