题目描述
编写一个程序,输入a、b、c三个值,输出其中最大值。
输入
一行数组,分别为a b c
输出
a b c其中最大的数
样例输入复制
10 20 30
样例输出复制
30
import java.util.Scanner;
public class Text03 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
System.out.println(max(a,b,c));
}
public static int max(int a,int b,int c){
int temp = 0;
if(a > b){
if(a > c)
temp = a;
else if(a < c)
temp = c; }
if(a < b){
if(b > c)
temp = b;
else if (b < c)
temp = c;
}
return temp;
}
}