试题

试题 试卷

logo

题型:单选题 题类:常考题 难易度:困难

浙江省2019届高三上学期稽阳10月联考信息技术试卷

【加试题】有如下程序段:

  Dim a(1 To 10) As Integer

  Dim i As Integer, j As Integer, m As Integer

  Dim key As Integer

  i = 1: j = 10: key = Val(Text1.Text)

  Do While i <= j

    m = (i + j) \ 2

    If key < a(m) Then

      j = m - 1

    ElseIf key > a(m) Then

      i = m + 1

    Else

      Do While m > 1

         If a(m - 1) = key Then

          m = m - 1

         Else

          Exit Do

         End If

      Loop

      Exit Do

    End If

  Loop

数组中a(1)到a(10)依次为“1,1,2,3,3,3,3,4,4,4”,若在文本框Text1中输入值3,经上述程序段执行后变量m的值为(  )

A、7 B、6 C、5 D、4
举一反三
【加试题】编写VB程序,实现如下功能:单击“生成密文”按钮Command2,在文本框Text3中产生与每个小写字母对应的密文(每个明文字母对应1个不重复的密文字母)。在文本框Text1中输入单词字符串,单击“加密”按钮Command1后,进行逐个字符加密,加密方法:在“明文”中找到相应字符,再得到明文对应位置的密文,并在文本框Text2中显示对应密文(运行效果如图17所示)。实现上述功能的VB代码如下:

 

Dim m2 As String

Private Sub Command1Click()

Dim flag(1 To 26) As Boolean

Dim num As Integer,t As Integer

Randomize

num = 1

Text3.Text = " "

For i = 1 To 26

    flag(i) = False

Next i

Do While num <= 26

    x = Int(Rnd * 26) + 97

          ①      

    If  flag(t) = False Then

    m2 = m2 + Chr(x)

    num = num + 1

      ②       

    End If

Loop

Text3.Text = m2

End Sub

Private Sub Command2Click()

Dim s As String, m As String, result As String

Dim k As String, c As Integer

s = Text1.Text

m = "abcdefghijklmnopqrstuvwxyz"

For i = 1 To Len(s)

    k = Mid(s, i, 1)

    If  k >= "A" And k <= "Z"  Then

    k = Chr(Asc(k) + 32)

    End If

    c = 1: continue = True

    Do While       ③       

    If k = Mid(m, c, 1) Then

    continue = False

    End If

    c = c + 1

    Loop

   ④     

Next i

Text2.Text = result

End Sub

程序①处的代码是{#blank#}1{#/blank#}

程序②处的代码是{#blank#}2{#/blank#}

程序③处的代码是{#blank#}3{#/blank#}

程序④处的代码是{#blank#}4{#/blank#}

返回首页

试题篮