JAVA 这代码问题

来源:百度知道 编辑:UC知道 时间:2024/05/06 17:54:46
import java.util.Scanner;

public class Bijiao {
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();
int d = sc.nextInt();
int e = sc.nextInt();
int f = sc.nextInt();
int g = sc.nextInt();
int h = sc.nextInt();
int i = sc.nextInt();
int j = sc.nextInt();
int max = a;

if(max<b){
max = b;
}
if(max<c){
max = c;
}
if(max<d){
max = d;
}
if(max<e){
max = e;
}
if(max<f){
max = f;
}
if(max<j){
max = j;
}
if(max<h){
max = h;
}
if(max<i){
max = i;
}
if(max<j){
max = j;
}
System.out.println("最大数是:"+max);

当然不能1到9都满足了.就和取最大的数一样,这里取的是处于max之后的最大数.完全一样.
要知道maxone在不断的变化.

另外应该用个int[] 和一个 for 循环来写.