3.16蓝桥杯练习

题目2

代码:

package test3_16;

public class test2 {
    public static int minMaxGame(int[] nums) {
            int n = nums.length;
            while(n != 1){
                int[]  newNums = new int[n / 2];
                for(int i=0;i< n/2;i++){
                    if(i % 2 == 0){
                        newNums[i] = Math.min(nums[2 * i], nums[2 * i + 1]);
                    }
                    else {
                        newNums[i] = Math.max(nums[2 * i], nums[2 * i + 1]);
                    }
                }

                nums = newNums;
                n = n / 2;
            }
            return nums[0];
    }

    public static void main(String[] args) {
        int[] nums = {1,3,5,2,4,8,2,2};
        System.out.println(minMaxGame(nums));
    }
}

运行截图:

题目3

代码:

package test3_16;

public class test1 {
    public static void main(String[] args) {
        System.out.print((int)(Math.pow(20,22) % 7 +6));
    }
}

运行截图:

猜你喜欢

转载自blog.csdn.net/m0_63911789/article/details/129591486