江苏省高等院校计算机等级考试vb书后习题答案 .pdf
《江苏省高等院校计算机等级考试vb书后习题答案 .pdf》由会员分享,可在线阅读,更多相关《江苏省高等院校计算机等级考试vb书后习题答案 .pdf(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、第 6 章 数组习题参考答案6-1 请同学上机运行代码。6-2 Option Explicit Option Base 1 Private Sub Command1_Click() Dim i As Integer, t As Integer Dim a(15) As Integer Randomize For i = 1 To 15 a(i) = Int(100 * Rnd) Text1 = Text1 & Str(a(i) Next i For i = 1 To 7 t = a(i) a(i) = a(16 - i) a(16 - i) = t Next i For i = 1 To 15
2、 Text2 = Text2 & Str(a(i) Next i End Sub Private Sub Command2_Click() Text1 = Text2 = End Sub Private Sub Command3_Click() End End Sub 6-3 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 17 页 - - - - - - - - - Option Explicit Dim a(20) As Integer Private Sub Com
3、mand1_Click() Dim i As Integer Randomize For i = 1 To 20 a(i) = Int(90 * Rnd) + 10 Text1 = Text1 & Str(a(i) Next i End Sub Private Sub Command2_Click() Dim i As Integer, j As Integer, f As Boolean Dim n As Integer For i = 1 To 20 f = True For j = i + 1 To 20 If a(i) = a(j) Then f = False Next j If f
4、 = True Then n = n + 1 Next i Text2 = n End Sub Private Sub Command3_Click() Text1 = End Sub Private Sub Command4_Click() End End Sub 6-4 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 17 页 - - - - - - - - - Option Explicit Dim a(20) As Integer Private Sub Comm
5、and1_Click() Dim i As Integer Randomize For i = 1 To 20 a(i) = Int(90 * Rnd) + 10 Text1 = Text1 & Str(a(i) Next i End Sub Private Sub Command2_Click() Dim i As Integer, j As Integer, max As Integer Dim n As Integer, w As Integer, p As Integer For i = 1 To 20 n = 0: p = i For j = 1 To 4 If i 20 Then
6、p = p - 20 n = n + a(p) Next j If n max Then max = n w = i End If Next i Text2 = max Picture1.Print w & - & w + 4 End Sub Private Sub Command3_Click() Text1 = End Sub Private Sub Command4_Click() End End Sub 6-5 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 17
7、 页 - - - - - - - - - Dim a(5, 5) As Integer Private Sub Command1_Click() For i = 1 To 4 For j = 1 To 5 a(i, j) = Int(9 * Rnd) + 1 Picture1.Print a(i, j); Next j Picture1.Print Next i End Sub Private Sub Command2_Click() For j = 1 To 5 s = 0 For i = 1 To 4 s = s + a(i, j) Next i Text1 = Text1 & Str(s
8、) Next j End Sub Private Sub Command3_Click() For i = 1 To 4 s = 0 For j = 1 To 5 s = s + a(i, j) Next j Text2 = Text2 & Str(s) & Chr(13) & Chr(10) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 17 页 - - - - - - - - - Next i End Sub Private Sub Command4_Click()
9、 Text1 = Text2 = Picture1.Cls End Sub Private Sub Command5_Click() End End Sub 6-6 Option Explicit Private Sub Command1_Click() Dim a(5, 5), i As Integer, j As Integer Dim n As Integer, m As Integer, t As Integer Randomize For i = 1 To 5 For j = 1 To 5 - 1 a(i, j) = Int(40 * Rnd) * 2 + 10 Next j Nex
10、t i For i = 1 To 5 For j = 5 To 6 - i Step -1 a(i, j) = Int(40 * Rnd) * 2 + 11 Next j Next i For i = 1 To 5 For j = 1 To 5 Text1 = Text1 & Str(a(i, j) Next j Text1 = Text1 & vbCrLf 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 17 页 - - - - - - - - - Next i End
11、 Sub 6-7 同 6-4 6-8 Dim a(5, 5) As Integer Private Sub Command1_Click() Randomize For i = 1 To 5 For j = 1 To 5 a(i, j) = Int(100 * Rnd) + 1 Picture1.Print Right( & a(i, j), 4); Next j Picture1.Print Next i End Sub Private Sub Command2_Click() For i = 1 To 5 For j = 1 To 5 s = s + a(i, j) Next j Next
12、 i Text1 = Str(s) End Sub Private Sub Command3_Click() For i = 1 To 5 For j = 1 To 5 If i = 1 Or j = 1 Or i = 5 Or j = 5 Then 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 17 页 - - - - - - - - - s = s + a(i, j) End If Next j Next i Text2 = Str(s) End Sub Priva
13、te Sub Command4_Click() For i = 1 To 5 For j = 1 To 5 If i = j Or j = 6 - i Then s = s + a(i, j) End If Next j Next i Text3 = Str(s) End Sub 6-9 Option Explicit Private Sub Command1_Click() Dim a() As Integer, i As Integer, j As Integer Dim max As Integer, k As Integer, f As Boolean Dim n As Integer
14、, m As Integer, t As Integer n = InputBox( 输入矩阵的行数:) m = InputBox( 输入矩阵的列数:) ReDim a(n, m) Randomize For i = 1 To n For j = 1 To m a(i, j) = Int(90 * Rnd) + 10 Text1 = Text1 & Str(a(i, j) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 17 页 - - - - - - - - - Nex
15、t j Text1 = Text1 & vbCrLf Next i For i = 1 To n max = 0 For j = 1 To m If a(i, j) max Then max = a(i, j) t = j End If Next j For k = 1 To n If a(k, t) n Then Picture1.Print 鞍点: ; a(i, t); 第; i; 行; t; 列 f = True End If Next i If f = False Then Picture1.Print 没有鞍点 End Sub Private Sub Command2_Click()
16、 Text1 = Picture1.Cls End Sub Private Sub Command3_Click() End End Sub 6-10 Option Explicit 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 17 页 - - - - - - - - - Private Sub Form_Click() Dim a() As Integer, n As Integer Dim i As Integer, j As Integer n = InputB
17、ox( 层数 ) ReDim a(n, n) For i = 1 To n Print Tab(20 - 2 * i); For j = 1 To i If i = 1 Or i = j Then a(i, j) = 1 Else a(i, j) = a(i - 1, j - 1) + a(i - 1, j) End If Print Left(a(i, j) & , 4); Next j Print Next i End Sub 6-11 Option Explicit Private Sub Command1_Click() Dim a(4, 5), i As Integer, j As
18、Integer Dim b(4) As Integer, max As Integer, min As Integer Dim n As Integer, m As Integer, t As Integer Randomize max = 0: min = 32767 For i = 1 To 4 For j = 1 To 5 a(i, j) = Int(90 * Rnd) + 10 Text1 = Text1 & Str(a(i, j) b(i) = b(i) + a(i, j) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - -
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 江苏省高等院校计算机等级考试vb书后习题答案 2022 江苏省 高等院校 计算机等级考试 vb 书后 习题 答案
限制150内