试题

试题 试卷

logo

题型:单选题 题类:常考题 难易度:普通

浙江省浙北G2两校2020-2021学年高二下学期信息技术期中联考试卷

有如下VB程序段:

Function fun(x As Integer) As Integer

    If x <= 2 Then

        fun = x

    Else

        fun = 2 * fun(x - 1) + fun(x - 2)

    End If

End Function

则表达式fun(5)的值为(   )

A、12 B、29 C、30 D、70
举一反三
简化的VB词频统计程序。程序功能为:在文本框Text1中输入一篇英文文章,在文本框Text2中输入一个英文单词,单机“统计”按钮Command1后,在文本框Text3中显示这个英文单词出现的次数。程序运行界面如图所示。

查找的英文单词由连续的ASCII英文字符(a~z或A~Z)组成。组合词程序会进行分解,如river-small可拆分为2个单词river和small,查找的英文单词不区分大小写。程序代码如下,但加框处代码有错,请改正:

Private Sub Command1_Click()

Dim article As String,f As String,count As Integer

Dim i As Intege,,begin As Integer,s As String

article=Text1.Text : f=Text2.Text : count=0

begin = 1

For i=1 To Len(article)

   t = Mid(article,i,1)

   If Not(t>="A"And t<="Z" Or t>="a" And t<="z") Then

     If i > begin Then

        s =      '①

        If LowerCase(f)=LowerCase(s) Then

            count = count+1

        End If

      End If

          begin = i + 1

     End If  

  Next i

    Text3.Text=Str(count)

End Sub

Function LowerCase(word As String) As String    '单词转化为全小写的形式

Dim i As Integer,c As String

For i=1 To Len(word)

   c = Mid(word,i,1)

   '小写英文字母的ASCII码值比大写字母的值大32

   If c>="A" And c<="Z" Then c =    '②

   LowerCase = LowerCase + c

Next i

End Function

以上程序段运行时,为了实现上述功能,加框处代码应改正为:

①{#blank#}1{#/blank#};②{#blank#}2{#/blank#}。

返回首页

试题篮