VB编程题求解

求 100与999之间最大的三个素数 要求过程
2025-01-05 06:11:01
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim mArr(2), i%, j%, k%
k = 0
For i = 999 To 100 Step -1

For j = 2 To Int(Sqr(i))
If i Mod j = 0 Then Exit For
If j = Int(Sqr(i)) Then
mArr(k) = i
Print i
k = k + 1
End If
Next j
If k = 3 Then Exit For
Next i
Print Join(mArr, ", ")
End Sub