【简答题】
Private arr(100) As Integer
Private Sub Command1_Click()
Open App.Path & "\in5.txt" For Input As #1
For i = 1 To 40
Input #1, arr(i)
Next
Close #1
End Sub
Private Sub Command2_Click()
'=================考生编写程序开始===================
???
'=================考生编写程序结束====================
Open App.Path & "\out5.txt" For Output As #1
Print #1, Label3.Caption, Label4.Caption
Close #1
End Sub
Public Function prime(x As Integer)
k = Int(Sqr(x) + 0.5)
For i = 2 To k
If x Mod i = 0 Then
prime = False
Exit Function
End If
Next
If i > k Then prime = True
End Function
参考答案
n = 0
For k = 1 To 40
If prime(arr(k)) Then
If n = 0 Then
mini = arr(k)
Else
If mini > arr(k) Then
mini = arr(k)
End If
End If
n = n + 1
End If
Next
Label3.Caption = Str(n)
Label4.Caption = Str(mini)