【正文】
計(jì)算 g2End Sub15。a(ni+1)) Next iEnd Sub程序4.Private Sub find(x() As Single,m As byte,n As Byte,ki As Byte,kj As Byte) xmax = x(1,1) ki = 1: kj = 1 For i = 1 To m For j = 1 To n If Abs(x(i, j)) Abs(xmax) Then xmax = x(i, j): ki = i: kj = j Next j, i End Sub程序5. Option ExplicitPublic Function g1(a%(), n%) As DoubleDim i%For i = 1 To n g1 = g1 + a(i) Next g1 = g1 / nEnd FunctionPublic Function g2(a%(), n%) As DoubleDim i%, tt = g1(a, n) For i = 1 To ng2 = g2 + (a(i) t) ^ 2Next ig2 = Sqr(g2) / nEnd Function39。a(n),a(2)243。 Next j PrintNext iEnd Sub第4章 函數(shù)與過(guò)程習(xí) 題一、判斷題1. 2.√ 3. 4. 5.√ 6. 7. 8.√9. √ 10. √二、填空題參考答案1.按地址傳送 2.b() As Long 3.6 4.按值傳遞 5.按地址傳遞6.Public x As Single 7.Static x As Integer 8. 9. function f9(a() as single,n) as single f10(a() as single ,n as integer)11. sub f10(a() as single ,m as integer,n as integer ,max as single,min as single)12. c=(a,b)三、程序閱讀題(寫出下列程序的運(yùn)行結(jié)果)程序1. s = 2 程序2. mand1 mand2 s = 5 1 1 s = 9 1 2 1 3 1 4程序3. Byref時(shí)分別輸出0 101 ,0 110 ,0 1011 ,0 10001 (注意:語(yǔ)句Print n。打印 i 個(gè)數(shù)字 Print Space(4 Len(Trim(Str(c(i, j))))) amp。 39。打印楊輝三角形,每個(gè)數(shù)字占 4列For i = 1 To n 39。 Next j PrintNext iEnd Sub(2)Private Sub Form_Click()Dim n As Integer, i As Integer, j As Integer, k As Integer, c%()Do ‘假設(shè)n范圍在 19 n = Val(InputBox(請(qǐng)輸入行數(shù)n:))Loop Until n 0 And n 10n = n + 1ReDim c(n, n)39。打印二維數(shù)組 For i = 1 To 5 For j = 1 To 5 Print a(i, j)。 Next iFor j = 1 To n For i = 1 To m If a(i) = b(j) Then Exit For Next i If i m Then Print b(j)。 i amp。 i amp。按公式計(jì)算 For j = i + 1 To 10 s = s + Sqr((x(i) x(j)) ^ 2 + (y(i) y(j)) ^ 2) NextNextPrintPrint 各點(diǎn)距離之和: amp。 )。 ,。生成10個(gè)坐標(biāo)點(diǎn) x(i) = Int(Rnd * 90) + 10 Print ( amp。 ^ ws = 0 Then Print i。 是同構(gòu)數(shù) End If Next iEnd Sub方法二Private Sub Form_Click()Dim iamp。將i轉(zhuǎn)字符型