要求:打开in5.txt,统计其中的40个整数,显示其中素数个数和最小素数

[复制链接]
查看11 | 回复1 | 2011-6-29 12:58:09 | 显示全部楼层 |阅读模式
Private arr(100) As Integer
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

prime = True
End Function
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

回复

使用道具 举报

千问 | 2011-6-29 12:58:09 | 显示全部楼层
这个不难, 但 vb 的我不会 。...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行