收藏 分享(赏)

程序填空.doc

上传人:cjc2202537 文档编号:267140 上传时间:2018-03-25 格式:DOC 页数:9 大小:109KB
下载 相关 举报
程序填空.doc_第1页
第1页 / 共9页
程序填空.doc_第2页
第2页 / 共9页
程序填空.doc_第3页
第3页 / 共9页
程序填空.doc_第4页
第4页 / 共9页
程序填空.doc_第5页
第5页 / 共9页
点击查看更多>>
资源描述

1、Option Explicit【程序说明】下列程序用来在窗体上输出如图 4-1 所示的数据。注意:不要删除* FILL *,否则影响评分成绩去掉_,填写代码。Private Sub Form_Click()Dim a(5, 5) As Byte, i As Byte, j As ByteFor i = 1 To 5For j = 1 To 6 - i*FILL*a(i, j) = i + j - 1Next j, iFor i = 2 To 5*FILL*For j = 7 - i To 5a(i, j) = j + i - 6Next j, iFor i = 1 To 5For j = 1

2、To 5Print a(i, j);Next j*FILL*PrintNext iEnd SubOption Explicit【程序说明】下面是一段计算数学表达式的程序。注意:不要删除* FILL *,否则影响评分成绩去掉_,填写代码。Private Sub Form_Click()Dim n As Integer, p As Integer, s As Single, q As Integer, i As Integern = InputBox(“请输入 N 的值:“)s = 0: p = -1: q = 1For i = 1 To n*FILL*p = -p: q = q * i*FILL

3、*s = s + p * i / q*FILL*Next iPrint sEnd SubOption ExplicitPrivate Sub Command1_Click()Dim a() As Byte, i As Integer, j As Integer, s As StringDim n As Integern = Val(Text1)ReDim a(n)a(1) = 1 计算并打印第一个数Picture1.Print Trim(Str(a(1)For i = 2 To n 计算其余行的数并打印*FILL*a(i) = a(i - 1)For j = j - 1 To 2 Step -

4、1*FILL*a(j) = a(j) + a(j - 1)Next jFor j = 1 To is = Trim(Str(a(j)Picture1.Print s + Space(Int(4 - Len(s) / 2 + 0.5);Next j*FILL*Picture1.PrintNext iEnd SubPrivate Sub Command2_Click()*FILL*Picture1.ClsEnd SubOption ExplicitDim A(3, 3) As Integer, B(3, 3) As Integer, C(3, 3) As IntegerPrivate Sub Co

5、mmand1_Click()Dim i%, j%Picture1.ClsFor i = 0 To 3For j = 0 To 3*FILL*A(i, j) = Int(Rnd * 41 + 30)Picture1.Print A(i, j);Next jPicture1.PrintNext iEnd SubPrivate Sub Command2_Click()Dim i%, j%Picture2.ClsFor i = 0 To 3For j = 0 To 3*FILL*B(i, j) = Int(Rnd * 35 + 101)Picture2.Print B(i, j);Next jPict

6、ure2.PrintNext iEnd SubPrivate Sub Command3_Click()Dim i%, j%Picture3.ClsFor i = 0 To 3For j = 0 To 3*FILL*C(i, j) = A(i, j) + B(i, j)Picture3.Print C(i, j);Next jPicture3.PrintNext iEnd SubPrivate Sub Command4_Click()Dim D%(3, 3), i%, j%Picture4.ClsFor i = 0 To 3For j = 0 To 3*FILL*D(i, j) = A(j, i

7、)Picture4.Print D(i, j);Next jPicture4.PrintNext iEnd SubPrivate Sub Command5_Click()Dim i%, j%, max%, n1%, n2%max = C(0, 0)n1 = 0n2 = 0Picture5.ClsFor i = 0 To 3For j = 0 To 3If C(i, j) max Then*FILL*max = C(i, j)*FILL*n1 = i*FILL*n2 = jEnd IfNext jNext iPicture5.Print “最大值为:“ “ ,下标为:C(“; n1; “,“;

8、n2; “)“End SubOption ExplicitPrivate Sub Command1_Click()Dim a(1 To 26) As Integer, c As String * 1, col As IntegerDim le As String, i%, j%Picture1.Clsle = Len(Text1) 求字符串的长度For i = 1 To le*FILL*c = Ucase(Mid(Text1, i, 1) If c = “A“ And c 0 Then*FILL*Picture1.Print “ “; Chr$(j + 64); “=“; a(j);*FILL

9、*col = col + 1*FILL*If col Mod 8 = 0 Then Picture1.PrintEnd IfNext jEnd SubOption Explicit【程序说明】以下程序产生 30 个两位随机整数、并按从小到大的顺序存入数组 a 中, 再将其中的奇数按从小到大的顺序在窗体中用紧凑格式输出。注意:不要删除* FILL *,否则影响评分成绩去掉_,填写代码。Private Sub Form_Click()Dim a(30) As Byte, i As Byte, j As Byte, m As Byte*FILL*For i = 1 To 30: a(i) = 10

10、+ Int(Rnd * 90): Next iFor i = 1 To 29*FILL*For j = i + 1 To 30If a(i) a(j) Then*FILL*m = a(i): a(i) = a(j): a(j) = mEnd IfNext j, iFor i = 1 To 30*FILL*If a(i) Mod 2 = 1 Then Print a(i);Next iEnd SubOption Explicit【程序说明】下列程序求两个正整数 m、n 的最大公约数。注意:不要删除* FILL *,否则影响评分成绩去掉_,填写代码。Private Sub Form_Click()

11、Dim m As Integer, n As Integer, r As Integerm = InputBox(“请输入 M 的值:“): n = InputBox(“ 请输入 N 的值:“)Print m; “和“; n; “ 的最大公约数是: “r = m Mod n*FILL*Do Until r = 0*FILL*m = n: n = r: r = m Mod nLoopPrint nEnd SubOption ExplicitDim a(1 To 20) As Integer, i%Private Sub Command1_Click()RandomizeFor i = 1 To

12、20*FILL*a(i) = Int(Rnd * 100 + 1)Picture1.Print a(i); “ “;*FILL*If i Mod 6 = 0 ThenPicture1.PrintEnd IfNext iEnd SubPrivate Sub Command2_Click()Dim max%, min%, ave%, temp%, i%max = a(1)min = a(1)ave = a(1)For i = 2 To 20*FILL*If a(i) max Then max = a(i)*FILL*If a(i) = 0 And a(i) = 60 And a(i) = 70 And a(i) = 80 And a(i) = 90 And a(i) = 100 Then s5 = s5 + 1NextPicture2.Print “0-59 的有:“ & s1 & “人“Picture2.Print “60-69 的有:“ & s2 & “人“Picture2.Print “70-79 的有:“ & s3 & “人“Picture2.Print “80-89 的有:“ & s4 & “人“Picture2.Print “90-100 的有:“ & s5 & “人“End Sub

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 高等教育 > 教育学

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报