当前位置: 高中信息技术 / 单选题
  • 1. 将长度为奇数的字符串s从首位字符开始依次存入a(1),a(n - 1),a(3),a(n - 3)...。如:字符串“xuankao”分存后得到a(1)=“x”,a(6)=“u”,a(3)=“a”,a(4)=“n”,a(5)=“k”,a(2)= “a”,a(7)= “o”,下列能实现该功能的程序段是(   )

    A . For i = 1 To Len(s)

        If I Mod 2= 0 Then

            a(i) = Mid(s, i, 1)

        Else

            a(Len(s) - i + 1) = Mid(s, i, 1)

        End If

    Next i B . For i = 1 To Len(s)

        If i Mod 2= 0 Then

            a(Len(s) - i+1) = Mid(s, i, 1)

        Else

            a(i) = Mid(s, Len(s) - i+1, 1)

        End If

    Next i C . For i = 1 To Len(s)

        If i Mod 2 = 1 Then

            a(i) = Mid(s, i, 1)

        Else

            a(Len(s) - i+1) = Mid(s, i, 1)

        End If

    Next i D . For i= 1 To Len(s)

        If i Mod 2 = 1 Then

            a(i) = Mid(s, i, 1)

        Else

            a(Len(s) - i+1) =Mid(s, Len(s) - i+1, 1)

        End If

    Next i

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