试题

试题 试卷

logo

题型:综合题 题类:模拟题 难易度:困难

浙江省杭州市2015年高考信息技术模拟卷4

只能被1和它本身整除的自然数。要求编写VB程序找出任意两个整数之间中所有的素数及个数,程序运行界面如下图所示。

请根据算法将下列程序补充完整。

Function prime(a As Integer) As Boolean

    Dim j As Integer

    prime = True

    j = 2

    Do While prime And j <= a \ 2

       If a Mod j = 0 Then

           prime = False

         Exit Do

       End If

            

         Loop

End Function

Private Sub Command1_Click( )

Dim i As Integer, a As Integer, b As Integer

Dim count As Integer

a = Val(Text1.Text)

b = Val(Text2.Text)

        For i = a To b

           If  = True Then

               List1.AddItem Str(i)

               count = count + 1

           End If

Next i

Label1.Caption = "素数共有" + Str(count) + "个!"

End Sub

举一反三
返回首页

试题篮