1、计算机语言b课后练习答案试验15-41Private Sub Command1_Click()Form1.ClsDim a(1 To 10) As Single, i As Integer, sum1 As Single, sum2 As Single, ave As Singlesum1 = 0sum2 = 0For i = 1 To 10a(i) = InputBox(请输入第 & i & 个数) If a(i) 0 Then sum1 = sum1 + a(i) If a(i) max Then max = a(i, j): s = i: t = j If a(i, j) min The
2、n min = a(i, j): k = i: l = j Next jNext iPrint 最大值:; max; Spc(2); 行号:; s; Spc(2); 列号:; tPrint 最小值:; min; Spc(2); 行号:; k; Spc(2); 列号:; lEnd Sub Private Sub Form_Load()Form1.FontSize = 12End Sub试验15-48暂缺!试验15-50Option Base 1Dim a%(1 To 10), i%, j%, b%, n%Private Sub Form_Click()For i = 1 To 10a(i) =
3、Rnd * 20 + 1Print a(i);NextPrintb = InputBox(输入要查找的数)Print 该数出现的位置:;n = 0For i = 1 To 10If a(i) = b Thenn = n + 1Print i;End IfNextPrintPrint 该数出现次数:; nEnd Sub Private Sub Form_Load()Form1.FontSize = 12End Sub试验15-50Option Base 1 Private Sub Form_Click()Form1.ClsDim a, i%, j%, x%a = Array(7, 6, 5, 1
4、, 8, 5, 3, 9, 4)Print 删除前的数组:;For i = 1 To 9 Print a(i);NextPrintx = InputBox(请输入要删除的数)For i = 1 To 9 If a(i) = x Then Exit ForNextIf i = 9 Then For j = i + 1 To UBound(a, 1) a(j - 1) = a(j) Next ReDim Preserve a(1 To UBound(a, 1) - 1)End IfPrint 删除后的数组:;For i = 1 To 8 Print a(i);NextEnd Sub Private
5、 Sub Form_Load()Form1.FontSize = 12Form1.FontBold = TrueEnd Sub试验15-53Private Type Studname As Stringeng As Singlemath As Singlevb As Singletotal As Singleave As SingleEnd TypeDim i As Integer Private Sub Form_Click()Form1.Print 姓名; Spc(4); 英语; Spc(4); 数学; Spc(4); vb; Spc(4); 总分; Spc(4); 平均分Printn =
6、 InputBox(输入人数)Dim s() As StudReDim s(n)For i = 1 To ns(i).name = InputBox(输入第 & i & 个学生姓名)s(i).eng = InputBox(输入第 & i & 个学生英语成绩)s(i).math = InputBox(输入第 & i & 个学生数学成绩)s(i).vb = InputBox(输入第 & i & 个学生vb成绩)Print s(i).name; Spc(4); s(i).eng; Spc(4); s(i).math; Spc(4); s(i).vb; Spc(4); s(i).eng + s(i).math + s(i).vb; Spc(4); Format(s(i).eng + s(i).math + s(i).vb) / 3, 0#)NextEnd Sub
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1