当前位置: 高中信息技术 / 单选题
  • 1. (2023高三下·浙江开学考) 有如下Python程序段:

    import random

    n = 8

    a = [random.randint(0, 9)

    for i in range(n)]

        for t in range(2):

            i = t + 1

            while i < n-1:

                if t % 2 == 0:

                    if a[i-1] < a[i] and a[i] > a[i+1]:

                        i += 2

                    else:

                        a[i] += random.randint(0, 9)

                else:

                    if a[i-1] > a[i] and a[i] < a[i+1]:

                        i += 2

            else:

                a[i] = random.randint(0, 9)

    运行后,数组a中的值可能是(   )

    A . [8, 8, 3, 5, 4, 7, 3, 5] B . [5, 11, 10, 18, 8, 9, 0, 2] C . [1, 2, 1, 4, 0, 10, -1, 7] D . [7, 12, 5, 17, 9, 19, -10, 8]

微信扫码预览、分享更方便