




已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
填空题11. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (1) ,最后一行是 (2) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim n As Long, k As Integer, a() As Integer n = 123456789 Do k = k + 1 ReDim Preserve a(k) a(k) = n Mod 100 n = n 100 Loop Until n = 0 For k = 1 To UBound(a) Print fun(a(k) Next kEnd SubPrivate Function fun(n As Integer) As Integer Dim k As Integer k = n Mod 10 fun = k * 10 + (n 10)End Function2. 执行下面程序,单击命令按钮Command1,则数组元素a(2, 1)的值是 (3) ,a(1, 2)的值是 (4) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim a(3, 3) As Integer, i As Integer, k As Integer Dim n As Integer n = 9 For k = 1 To 3 For i = 1 To 3 a(i, k) = n n = n - 1 Next i Next k For i = 1 To 3 For k = 1 To 3 Print a(i, k); Next k Print Next iEnd Sub3. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (5) ,第二行是 (6) ,第三行是 (7) 。Option ExplicitPrivate Sub Command1_Click() Dim i As Integer, a As Integer, b As Integer a = 1 b = 2 i = a Do While fun(i, b) = 7 i = i + a b = b + 1 Print i LoopEnd SubPrivate Function fun(ByVal x As Integer, y As Integer) As Integer x = x + 1 y = y + 1 fun = x + y Print funEnd Function4. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (8) ,第二行是 (9) ,最后一行是 (10) 。Option ExplicitDim k As Integer k为模块级变量Private Sub Command1_Click() Dim N As Integer, M As Integer, Lcm As Integer N = 6 M = 9 Lcm = Rec(N, M) Print LcmEnd SubPrivate Function Rec(A As Integer, B As Integer) As Integer k = k + 1 Print A If A Mod B = 0 Then Rec = A Else Rec = Rec(A + A / k, B) End IfEnd Function25. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (1) ,第三行是 (2) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim s As String, k As Integer Dim q As String, a() As String, n As Integer s = ABCDEFG n = 1 Do k = k + 1 ReDim Preserve a(k) a(k) = Mid(s, n, n) n = n + 1 Loop While n + Len(a(k) = Len(s) For n = 1 To UBound(a) q = Call sub1(a(n), q) Print q Next nEnd SubPrivate Sub sub1(s As String, q As String) Dim i As Integer For i = 1 To Len(s) q = Mid(s, i, 1) & q Next iEnd Sub6. 执行下面程序,单击命令按钮Command1,则数组元素a(1, 2)的值是 (3) ,a(3, 1)的值是 (4) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim a(3, 3) As Integer, i As Integer, j As Integer For i = 1 To 3 For j = 1 To 3 If (i + j) Mod 2 = 0 Then a(i, j) = i + j Else a(i, j) = (i * 3 + j) / 2 End If Print a(i, j); Next j Print Next iEnd Sub7. 执行下面程序,单击命令按钮Command1,则数组元素a(5)的值是 (5) ,窗体上显示的第二行是 (6) ,第三行是 (7) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim i As Integer, a(5) As Integer, j As Integer For i = 1 To 5 a(i) = 2 * i - 1 Print a(i); Next i Print For i = a(5) To a(3) Step -1 Print fun(i, a(i - 4) Next iEnd SubPrivate Function fun(a As Integer, b As Integer) As Integer a = a - 1 b = b - 1 fun = (a + b) / 2End Function8. 执行下面程序,单击命令按钮Command1,则数组元素yz(1)的值是 (8) ,数组元素yz(3)的值是 (9) ,窗体上显示的最后一行是 (10) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim n As Integer, yz() As Integer, s As Integer Dim i As Integer n = 12 Call sub1(n, yz) For i = 1 To UBound(yz) s = s + yz(i) Print yz(i) Next i Print sEnd SubPrivate Sub sub1(n As Integer, a() As Integer) Dim k As Integer, i As Integer For i = 2 To n / 2 If n Mod i = 0 Then k = k + 1 ReDim Preserve a(k) a(k) = i End If Next iEnd Sub39. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (1) ,第三行是 (2) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim s As String, k As Integer, a() As String, i As Integer s = VBASIC i = 1 Do k = k + 1 ReDim Preserve a(k) a(k) = Mid(s, i, i) i = i + 1 Loop While i + Len(a(k) - 1 = Len(s) For k = 1 To UBound(a) Print fun(a(k) Next kEnd SubPrivate Function fun(s As String) As String Dim k As Integer, t As String For k = Len(s) To 1 Step -1 t = t & Mid(s, k, 1) Next k fun = tEnd Function10. 执行下面程序,单击命令按钮Command1,则数组元素a(2, 1)的值是 (3) ,a(1, 3)的值是 (4) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim a(3, 3) As Integer, i As Integer, j As Integer Dim k As Integer, n As Integer k = 2 n = 1 Do While k = 6 For i = 1 To 3 For j = 1 To 3 If i + j = k Then a(i, j) = n: n = n + 1 Next j Next i k = k + 1 Loop For i = 1 To 3 For j = 1 To 3 Print a(i, j); Next j Print Next iEnd Sub11. 执行下面程序,单击命令按钮Command1,则数组元素a(3)的值是 (5) ,窗体上显示的第二行是 (6) ,第四行是 (7) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim i As Integer, a(5) As Integer, j As Integer For i = 1 To 5 a(i) = 2 * i - 1 Print a(i); Next i Print j = UBound(a) For i = j To 2 Step -1 Print fun(a(i), a(i - 1) Next iEnd SubPrivate Function fun(ByVal a As Integer, b As Integer) As Integer fun = (a + b) / 2 a = a + 1 b = b + 1End Function12. 执行下面程序,单击命令按钮Command1,则窗体上显示的第一行是 (8) ,第二行是 (9) ,最后一行是 (10) 。Option ExplicitPrivate Sub Command1_Click() Dim n As Integer, k As Integer n = 59 k = 5 Print Tran(n, k)End SubPrivate Function Tran(n As Integer, k As Integer) As String Dim r As Integer If n 0 Then r = n Mod k Tran = Tran(n k, k) & r Print r End IfEnd Function41. 已知在列表框中有5个列表项,从上到下内容分别为0、1、2、3、4。执行下面程序,单击窗体后,列表框上显示的第二个列表项内容是 (1) ,列表框中共有 (2) 项。Option ExplicitPrivate Sub Form_Click() Dim i As Integer For i = 0 To List1.ListCount / 2 - 1 List1.RemoveItem i Next iEnd Sub2. 执行下面程序,单击命令按钮Command1,在弹出的InputBox对话框中输入8,并按“确定”按钮,则a(1)的值是 (3) ,a(5)的值是 (4) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim a() As Integer, i As Integer, n As Integer n = InputBox(输入N, , 8) ReDim a(n) Call process(a, 1, 1) For i = 1 To n Print a(i) Next iEnd SubPrivate Sub process(a() As Integer, m As Integer, n As Integer) Dim i As Integer i = UBound(a) a(i) = m a(i - 1) = n i = i - 2 Do While i = 1 a(i) = a(i + 1) + a(i + 2) i = i - 1 LoopEnd Sub3. 执行下列程序,单击Command1按钮后,窗体上第一行为 (5) ,第二行为 (6) ,最后一行为 (7) 。Option ExplicitDim n As IntegerPrivate Sub Command1_Click() Dim i As Integer n = 1 For i = 1 To 5 Call Sub1(i, n) Print n Next i Print iEnd SubPrivate Sub Sub1(x As Integer, y As Integer) Dim i As Integer n = n + 2 x = x + 2 y = y + xEnd Sub4. 执行下面程序,单击Command1按钮,则在窗体上显示的第一行内容是 (8) ,第三行内容是 (9) ,最后一行内容是 (10) 。Option ExplicitPrivate Sub Command1_Click() Dim a As Integer, b As Integer a = 3 b = 1 Call P1(a, b) Print b Call P1(b, a) Print bEnd SubPrivate Sub P1(x As Integer, ByVal y As Integer) Static z As Integer x = x + z y = x - z z = 10 - y Print zEnd Sub51. 执行下面的程序,单击命令按钮Command1,则窗体上显示的第一行是 (1) ,最后一行是 (2) 。Option ExplicitPrivate Sub Command1_Click() Dim m(10) As Integer, k As Integer, x As Integer For k = 1 To 10 m(k) = 11 - k Next k x = 3 Print m(2 + m(x) Print m(m(x - 1) + m(x + 1) - 6) * 2 If m(2 + m(x) 3 Then Print x + m(k + m(k - 1) - 9) Else Print x - m(k + m(k - 1) - 9) End IfEnd Sub2. 执行下面的程序,单击命令按钮Command1,则图片框Picture2中显示的第一行是 (3) ,第二行是 (4) ,第三行是 (5) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim sa(3, 3) As String * 1, i As Integer, j As Integer, s As String, k As Integer s = ABCDEFXYZ k = 1 For i = 1 To 3 For j = 1 To 3 sa(i, j) = Mid(s, k, 1) Picture1.Print sa(i, j); k = k + 1 Next j Picture1.Print Next i For i = 1 To 3 For j = 1 To 3 k = (Asc(sa(i, j) - Asc(A) + i + j) Mod 26 sa(i, j) = Chr(k + Asc(A) Picture2.Print sa(i, j); Next j Picture2.Print Next iEnd Sub3. 执行下面的程序,单击命令按钮Command1,则窗体上显示的第一行是 (6) ,第二行是 (7) ,最后一行是 (8) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim a As Integer, b As Integer, c As Integer a = 6 b = 20 c = Fun(a, b) Print bEnd SubPrivate Function Fun(ByVal x As Integer, y As Integer) As Integer x = x - 2 y = y - 3 If x = 0 Or y = 0 Then Fun = 1 Else Fun = Fun(x - 2, y - 3) End If Print xEnd Function4. 执行下面程序,单击命令按钮Command1,则在窗体上显示的第二行是 (9) ,最后一行是 (10) 。Option ExplicitDim b As IntegerPrivate Sub Command1_Click() Dim a As Integer, i As Integer a = 8 For i = 1 To 3 Print F(a) Next iEnd SubFunction F(a As Integer) As Integer Static c As Integer b = b + 1 c = c + 2 F = a + b - cEnd Function61. 执行下面程序,单击命令按钮Command1,若文本框Text1中生成的数据为“8 6 6 3 4 8”,则列表框List1中共输出 (1) 行数据,其中第一行为 (2) ,最后一行为 (3) 。Option ExplicitPrivate Sub Command1_Click() 运行 Dim a(6) As Integer, b(1 To 10) As Integer Dim i As Integer For i = 1 To 6 a(i) = 1 + Int(Rnd * 10) Text1.Text = Text1.Text & Str(a(i) Next i Call num(a, b) For i = 1 To 10 If b(i) 0 Then List1.AddItem b(i) Next iEnd SubPrivate Sub num(x() As Integer, y() As Integer) Dim i As Integer For i = 1 To 6 y(x(i) = y(x(i) + 1 Next iEnd Sub2. 执行下面程序,单击命令按钮Command1,则窗体上输出的data数组元素个数为 (4) ,最后一行是 (5) 。Option ExplicitOption Base 1Private Sub Command1_Click() Dim st As String, char As String Dim data() As String, i As Integer, j As Integer st = 66*97*115*105*99* For i = 1 To Len(st) If Mid(st, i, 1) * Then char = char & Mid(st, i, 1) Else j = j + 1 ReDim Pres
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年工业互联网平台增强现实交互技术在虚拟现实制造中的应用分析报告
- 2025年环保纸包装市场策略分析报告
- 涉水急救理论知识培训总结
- 2025年汽车芯片短缺应对策略:新能源汽车产业链挑战与机遇报告
- 2025年基因治疗药物研发策略与临床实验进展深度分析报告
- 2025年生鲜新零售行业供应链优化策略深度分析报告
- 2025年文化与科技结合数字博物馆虚拟导览技术创新模式研究报告
- 涉外计算机基础知识培训课件
- 公司培训员工课件
- 幽默的培训课件图片
- GB/T 45953-2025供应链安全管理体系规范
- 2025年秋季开学第一课《翻越你的浪浪山》课件
- DB11∕T 510-2024 公共建筑节能工程施工质量验收规程
- GB/T 33982-2017分布式电源并网继电保护技术规范
- 注册会计师CPA《公司战略与风险管理》课件
- 【2020】高中英语人教版必修一词汇 词性转换
- 部编版小学六年级上册《道德与法治》全册复习课件
- GJB标准化大纲
- 钢筋混凝土排水管二级管配筋设计图册
- 同济大学复变函数复变函数与积分变换课件
- 教导处行事历
评论
0/150
提交评论