试题

试题 试卷

logo

题型:填空题 题类:常考题 难易度:困难

浙江省高一下学期信息技术期末考试试卷

设有n盏灯,放在一排。从1 到 n依次顺序编号。有 n个人也从1到n依次编号。第1个人(1号)将灯全部关闭,第2个人(2号)将凡是2的倍数的灯打开,第3个人(3号)将凡是3的倍数的灯做相反处理(该灯如果为打开的,则将它关闭,如关闭的将它打开),以后的人和3号一样,将凡是自己号数倍数的灯做相反处理。问当n个人操作后,哪几盏灯是亮的。(亮灯为0,关闭为1)

为了实现这一目标,完善下列程序,使之能完成该功能。

Private Sub command1_click()

   Const n=20

   Dim i as integer,j as integer

   Dim a(1 to n) as integer

   For j=1 to n

      a(j)=0

   next j

   for i=1 to n

      for j=1 to n

         if j mod i=0 then

            

         End if

       Next j

    Next i

    For j=1 to n

       If  then list1.additem str(j)

    Next j

End Sub

举一反三
简化的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#}。

返回首页

试题篮