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

    Const n=5

    Dim a(1 to n) as integer, i as integer, j as integer, k as integer, t as integer

    For i=1 to n

        a(i)=int(rnd*20+1)

    Next i

    For i=1 to n-1

        k=i

        For j=i+1 to n

            If a(j) mod 2=1 then

                If a(k) mod 2=0 or a(j)>a(k) then k=j

                ElseIf a(k) mod 2=0 and a(j)>a(k) then

                    k=j

            End if

        Next j

        If k<>i then t=a(k): a(k)=a(i): a(i)=t

    Next i

    该程序段运行结束后,a(1)~a(5)可能是(     )

    A . 20 18 17 15 13 B . 2 3 4 5 6 C . 13 3 18 8 6 D . 16 14 8 11 5

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