package Code411;
//求数组的最大值
public class CodeArrayMax {
public static void main(String[] args) {
int array[]={5,15,30,20,100};
int max=array[0];
for (int i = 1; i < array.length; i++) {
//若比max大,则换
if(array[i]>max){
max=array[i];
}
}
System.out.println("最大值"+max);
}
}
//最小值反之
↓运行结果
JAVA 求数组中的最大值

 

 

相关文章:

  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
  • 2022-01-17
相关资源
相似解决方案