1 / 8
文档名称:

南京医科大学VB操作平台实验题代码.docx

格式:docx   大小:13KB   页数:8页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

南京医科大学VB操作平台实验题代码.docx

上传人:碎碎念的折木 2022/6/23 文件大小:13 KB

下载得到文件列表

南京医科大学VB操作平台实验题代码.docx

相关文档

文档介绍

文档介绍:Visual Basic 程序设计平台实验题(二)
【实验一】二维方阵求对角线和(p55)
Option Base 1
Dim a() As Integer, i As Integer, j As Integer, n As In0) a(i, j);
Next j Next i
For i = 1 To n For j = 1 To n
a(j, i); Next j
Next i End Sub
【实验四】去max、min 求平均值(p70)
Option Explicit
Private Sub Command1_Click()
Dim score(8) As Single, i As Integer, max As Single, min As Single, av As Single, sum As Single
For i = 1 To 8
score(i) = (Int(Rnd * 31) + 70) / 10 Text1 = Text1 & Str(score(i)) & " " sum = sum + score(i)
Next i
Call maxmin(score, max, min) av = (sum - max - min) / 6 Text2 = av
End Sub
Private Sub maxmin(a() As Single, max As Single, min As Single)
Dim i As Integer
max = a(1): min = a(1) For i = 1 To 8
If a(i) > max Then max = a(i)
ElseIf a(i) < min Then min = a(i)
End If Next i End Sub
【实验五】验证哥德巴赫猜想,任意一大于2 的偶数可表为两个素数之和(P78)
Option Explicit
Private Function judge(n As Integer) As Boolean Dim i As Integer
For i = 2 To Sqr(n)
If n Mod i = 0 Then Exit For Next i
judge = True End Function
Private Sub Command1_Click()
Dim x As Integer, i As Integer x = Val()
If x = 4 Then Text2 = "2+2"
Else i = 3
Do While Text2 = ""
If judge(i) = True And judge(x - i) = True Then Text2 = i & "+" & x - i
Else
i = i + 2 End If Loop End If End Sub
Private Sub Command2_Click() = "