第一种办法运用if -else进行循环遍历
代码如下
package kaoyan;
import java.util.Scanner;
public class MaxAvgDemo {
public int getMax(int a,int b,int c){
if (a > b && a > c){
return a;
} else if (b > a && b > c) {
return b;
}else {
return c;
}
}
public int getMin(int a,int b,int c){
if (a < b && a < c){
return a;
} else if (b < a && b < c) {
return b;
}else {
return c;
}
}
public double getAvg(int a ,int b ,int c){
int sum = a+b+c;
return (sum*1.0/3);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入三个不同的数字:");
int num1 = sc.nextInt();
int num2 = sc.nextInt();
int num3 = sc.next