public class Test02 {
public static void main(String[] args) {
int score[]= {21,92,95,44,85,26};
int max;
int min;
max=min=score[0];
for(int x=0;x<score.length;x++){
if(score[x]>max){
max=score[x];
}
if(score[x]<min){
min=score[x];
}
}
System.out.println("最大数值"+max);
System.out.println("最小数值"+min);
}
}
结果:
最大数值95
最小数值21