冥灭

导航

 

//数组找最值
public void arrayMax() {
    int[] num = {2,5,9,1,7,3};
    int max = num[0];
    for(int i = 1;i < num.length;i++) {
        if(max < num[i]) {
            int temp = num[i];
            num[i] = max;
            max = temp;
        }
    }
    //获取最大值
    System.out.print(max);
}

posted on 2019-11-09 16:32  private_mingmie  阅读(185)  评论(0)    收藏  举报