BB平臺(tái)(VB日常測(cè)試)過(guò)程與函數(shù)_第1頁(yè)
BB平臺(tái)(VB日常測(cè)試)過(guò)程與函數(shù)_第2頁(yè)
BB平臺(tái)(VB日常測(cè)試)過(guò)程與函數(shù)_第3頁(yè)
BB平臺(tái)(VB日常測(cè)試)過(guò)程與函數(shù)_第4頁(yè)
BB平臺(tái)(VB日常測(cè)試)過(guò)程與函數(shù)_第5頁(yè)
已閱讀5頁(yè),還剩49頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 問(wèn)題 1 得 2.22 分,滿分 20 分   編寫(xiě)一子過(guò)程,將數(shù)組a(n, n)轉(zhuǎn)置。  正確答案所選答案1. Public Sub ff(a() As Single, n As Integer) 1.Public Sub ff(a() As Single, n As Integer) 2. Dim i As Integer, j As Integer, t As Single -未給定 3. For i = 2 To nFor j = 1 To i-1-未給定 4. t = a(i, j) -未給定 5. a(i, j) = a(j, i) -未給定 6.

2、a(j, i) = t -未給定 7. Next j -未給定 8. Next i -未給定 9. End Function -未給定   問(wèn)題 2 得 0 分,滿分 20 分   求下面表達(dá)式的值,并在窗體上輸出。要求m與n的值在窗體單擊事件中用Inputbox()函數(shù)輸入,且同為正整數(shù),m>n。通過(guò)函數(shù)過(guò)程實(shí)現(xiàn)求階乘的功能。 Private Sub Form_Click()    Dim m As Integer, n As Integer   Do m = InputBox(&quo

3、t;m=", "m>0,m必須大于n")n = InputBox("n=", "n>0")   Loop While m <= n Or m < 0 Or n < 0   Print fact(m) / fact(n) / fact(m - n)End Sub 正確答案所選答案1. Private Function fact(ByVal k As Integer) As Long -未給定 2. Dim i As Integer -未給定 3. fact

4、= 1 -未給定 4. For i = 2 To k -未給定 5. fact = fact * i -未給定 6. Next i -未給定 7. End Function -未給定   問(wèn)題 3 得 0 分,滿分 20 分   編寫(xiě)一個(gè)將一維數(shù)組倒置存放的子過(guò)程,并編寫(xiě)簡(jiǎn)單事件驗(yàn)證子過(guò)程的正確性。 Private Sub Form_Click()Dim b(6) As SingleFor i = 1 To 6   b(i) = InputBox(“b(” + Str(i) + “)=”)    Print b(i

5、),Next IPrintCall rev(b(), 6)    For i = 1 To 6   Print b(i),   Next iEnd Sub 正確答案所選答案1. Public Sub rev(x() As Double, n As Integer) -未給定 2. Dim i As Integer, t As Double -未給定 3. For i = 1 To n 2 -未給定 4. t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t -未給定 5. Next i -未給定 6.

6、End Sub -未給定   問(wèn)題 4 得 0 分,滿分 20 分   輸入n后,再輸入n個(gè)數(shù)a1 ,a2 ,.,an ,按照下列公式計(jì)算s的值并顯示。 編寫(xiě)事件過(guò)程Command1_Click(),計(jì)算s值,其中 v 值要求調(diào)用函數(shù)過(guò)程 f 來(lái)完成。已知求v值的函數(shù)過(guò)程 f程序如下。Private Function f (x() As Single, n As Integer) as single   Dim i As Integer   For i = 1 To n f = f + x(i) 

7、;  Next i   f = f / nEnd Function 正確答案所選答案1. Private Sub Command1_Click() -未給定 2. Dim a() As Single, n As Integer, s As SingleDim v As Single, i As Integer-未給定 3. n = InputBox("請(qǐng)輸入n的值")ReDim a(n)-未給定 4. For i = 1 To n -未給定 5. a(i) = InputBox("") -未給定 6. Next iv = f

8、(a, n)-未給定 7. For i = 1 To n -未給定 8. s = s + ( a(i) - v ) 2 -未給定 9. Next i -未給定 10. s = Sqr(s) / n -未給定 11. Print s -未給定 12. End Sub -未給定   問(wèn)題 5 得 0 分,滿分 20 分   編寫(xiě)Sub過(guò)程求一元二次方程的實(shí)數(shù)解,并通過(guò)事件過(guò)程調(diào)用它。 Private Sub Command1_Click()   Dim a As Double, b As Double, c As Double, y1 A

9、s Double, y2 As Double   a = 3: b = 1: c = 5   If root(a, b, c, y1, y2) Then Print y1, y2   Else Print "方程無(wú)實(shí)數(shù)解!"   End IfEnd Sub 正確答案所選答案1. Private Function root(ByVal a As Double, ByVal b As Double, ByVal c As Double, x1 As Double, x2 As D

10、ouble) As Boolean -未給定 2. Dim d As Double -未給定 3. d = b * b - 4 * a * c -未給定 4. If d < 0 Then -未給定 5. root = False -未給定 6. Else -未給定 7. root = Truex1 = (-b + Sqr(d) / (2 * a): x2 = (-b - Sqr(d) / (2 * a)-未給定 8. End If -未給定 9. End Function -未給定 問(wèn)題 1 得 0 分,滿分 20 分   編寫(xiě)一子過(guò)程,將數(shù)組a(n, n)轉(zhuǎn)置。 

11、正確答案所選答案1. Public Sub ff(a() As Single, n As Integer) -未給定 2. Dim i As Integer, j As Integer, t As Single -未給定 3. For i = 2 To nFor j = 1 To i-1-未給定 4. t = a(i, j) -未給定 5. a(i, j) = a(j, i) -未給定 6. a(j, i) = t -未給定 7. Next j -未給定 8. Next i -未給定 9. End Function -未給定   問(wèn)題 2 得 0 分,滿分 20 分 

12、60; 兩質(zhì)數(shù)的差為2,稱(chēng)此兩質(zhì)數(shù)為質(zhì)數(shù)對(duì),設(shè)計(jì)一個(gè)程序找出100以?xún)?nèi)的質(zhì)數(shù)對(duì),并在窗體上成對(duì)顯示結(jié)果。要求質(zhì)數(shù)的判斷用自定義函數(shù)完成。  正確答案所選答案1. Private Function prime(ByVal k As Integer) As Boolean -未給定 2. Dim i As IntegerIf k < 2 Then -未給定 3. prime = False -未給定 4. Else -未給定 5. For i = 2 To Sqr(k) -未給定 6. If k Mod i = 0 Then Exit For -未給定 7. Next iIf i

13、> Sqr(k) Then prime = True Else prime = False-未給定 8. End If -未給定 9. End FunctionPrivate Sub Form_Click()-未給定 10. Dim n As Integer -未給定 11. For n = 3 To 100 Step 2 -未給定 12. If prime(n) And prime(n + 2) Then Print n; n + 2 -未給定 13. Next n -未給定 14. End Sub -未給定   問(wèn)題 3 得 0 分,滿分 20 分  

14、編寫(xiě)子過(guò)程,將某數(shù)組中元素按值從大到小排序,并在窗體的單擊事件中,編寫(xiě)簡(jiǎn)單程序驗(yàn)算其正確性。 Private Sub Form_click()   Dim x(10) As Single, i As Integer   Print "排序前:"   For i = 1 To 10 x(i) = InputBox("b(" + Str(i) + ")=") Print x(i);   Next i   Pri

15、nt   Call sort(x(), 10)   Print "排序后:"   For i = 1 To 10 Print x(i);   Next iEnd Sub 正確答案所選答案1. Private Sub sort(a() As Single, ByVal n As Byte) -未給定 2. Dim i As Byte, j As Byte, k As Byte, temp As Single -未給定 3. For i = 1 To n - 1 -未給定 4. k = i

16、 -未給定 5. For j = i + 1 To n -未給定 6. If a(j) > a(k) Then k = j -未給定 7. Next j -未給定 8. temp = a(k): a(k) = a(i): a(i) = temp -未給定 9. Next i -未給定 10. End Sub -未給定   問(wèn)題 4 得 0 分,滿分 20 分   編寫(xiě)Sub過(guò)程求一元二次方程的實(shí)數(shù)解,并通過(guò)事件過(guò)程調(diào)用它。 Private Sub Command1_Click()   Dim a As Double, b As

17、Double, c As Double, y1 As Double, y2 As Double   a = 3: b = 1: c = 5   If root(a, b, c, y1, y2) Then Print y1, y2   Else Print "方程無(wú)實(shí)數(shù)解!"   End IfEnd Sub 正確答案所選答案1. Private Function root(ByVal a As Double, ByVal b As Double, ByVal c As Doub

18、le, x1 As Double, x2 As Double) As Boolean -未給定 2. Dim d As Double -未給定 3. d = b * b - 4 * a * c -未給定 4. If d < 0 Then -未給定 5. root = False -未給定 6. Else -未給定 7. root = Truex1 = (-b + Sqr(d) / (2 * a): x2 = (-b - Sqr(d) / (2 * a)-未給定 8. End If -未給定 9. End Function -未給定   問(wèn)題 5 得 0 分,滿分 20

19、 分   編寫(xiě)一個(gè)將一維數(shù)組倒置存放的子過(guò)程,并編寫(xiě)簡(jiǎn)單事件驗(yàn)證子過(guò)程的正確性。 Private Sub Form_Click()Dim b(6) As SingleFor i = 1 To 6   b(i) = InputBox(“b(” + Str(i) + “)=”)    Print b(i),Next IPrintCall rev(b(), 6)    For i = 1 To 6   Print b(i),   Next iEnd Sub 正確答案所選答案1. Public

20、 Sub rev(x() As Double, n As Integer) -未給定 2. Dim i As Integer, t As Double -未給定 3. For i = 1 To n 2 -未給定 4. t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t -未給定 5. Next i -未給定 6. End Sub -未給定 問(wèn)題 1 得 0 分,滿分 20 分   編寫(xiě)一個(gè)將一維數(shù)組倒置存放的子過(guò)程,并編寫(xiě)簡(jiǎn)單事件驗(yàn)證子過(guò)程的正確性。 Private Sub Form_Click()Dim b(6) As Sing

21、leFor i = 1 To 6   b(i) = InputBox(“b(” + Str(i) + “)=”)    Print b(i),Next IPrintCall rev(b(), 6)    For i = 1 To 6   Print b(i),   Next iEnd Sub 正確答案所選答案1. Public Sub rev(x() As Double, n As Integer) -未給定 2. Dim i As Integer, t As Double -未給定 3. For i =

22、 1 To n 2 -未給定 4. t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t -未給定 5. Next i -未給定 6. End Sub -未給定   問(wèn)題 2 得 0 分,滿分 20 分   驗(yàn)證哥德巴赫猜想大于6的偶數(shù)可以分解為兩個(gè)素?cái)?shù)之和,調(diào)用函數(shù)過(guò)程實(shí)現(xiàn)判斷任一正整數(shù)是不是素?cái)?shù)。 Private Function prime(ByVal n As Integer) As Boolean   Dim i As Integer   prime = True

23、     For i = 2 To Sqr(n)If n Mod i = 0 Then prime = False: Exit For   Next iEnd Function 正確答案所選答案1. Private Sub Form_Click() -未給定 2. Dim n1 As Integer, n2 As Integer, n As Integer -未給定 3. Don = InputBox("輸入一個(gè)大于6 的偶數(shù)")-未給定 4. Loop While n <= 6 Or n Mod 2 <>

24、 0 -未給定 5. For n1 = 3 To n / 2 Step 2 -未給定 6. n2 = n - n1 -未給定 7. If prime(n1) And prime(n2) Then -未給定 8. Print n; "=" n1; "+" n2Exit For-未給定 9. End If -未給定 10. Next n1 -未給定 11. End Sub -未給定   問(wèn)題 3 得 0 分,滿分 20 分   編寫(xiě)函數(shù)過(guò)程,計(jì)算某一維數(shù)組的最大值,并在窗體的單擊事件中,驗(yàn)算其正確性。 Private

25、Sub Form_Click()   Dim a(10) As Integer   For i = 1 To 10 a(i) = Int(Rnd * 90) + 10 Print a(i);   Next i   Print   Print "最大值是:" fmax(a(), 10)End Sub 正確答案所選答案1. Private Function fmax(x() As Integer, ByVal n As Byte) As Integer -未給

26、定 2. fmax = x(1) -未給定 3. For i = 2 To n -未給定 4. If x(i) > fmax Then fmax = x(i) -未給定 5. Next i -未給定 6. End Function -未給定   問(wèn)題 4 得 0 分,滿分 20 分   從1到10000中找出這樣的數(shù),該數(shù)各個(gè)位的數(shù)字的階乘相加之和等于該數(shù),并將結(jié)果輸出。要求調(diào)用fact函數(shù)過(guò)程計(jì)算階乘。 Private Function fact(ByVal k As Integer) As Long   Dim i As I

27、nteger   fact = 1   For i = 2 To k fact = fact * i   Next iEnd Function 正確答案所選答案1. Private Sub Form_Click() -未給定 2. Dim k As Integer, a As String, n As Long, i As IntegerDim p As Integer-未給定 3. For k = 1 To 10000 -未給定 4. a = LTrim(Str(k)n = 0-未給定 5. For i = 1

28、To Len(a) -未給定 6. p = Val( Mid(a, i, 1) ) -未給定 7. n = n + fact( p ) -未給定 8. Next i -未給定 9. If n = k Then Print k -未給定 10. Next k -未給定 11. End Sub -未給定   問(wèn)題 5 得 0 分,滿分 20 分   編程,使窗體的背景色在四種顏色間變換。第一次單擊窗體是紅色;第二次單擊窗體是綠色;第三次單擊窗體是藍(lán)色;第四次單擊窗體是黃色;第五次又重新開(kāi)始。要求其中使用靜態(tài)變量。  正確答案所選答案1. Private Su

29、b Form_Click() -未給定 2. Static flag As Integer -未給定 3. flag = flag + 1-未給定 4. Select Case flagCase 1 -未給定 5. BackColor = vbRedCase 2-未給定 6. BackColor = vbGreenCase 3-未給定 7. BackColor = vbBlueCase 4-未給定 8. BackColor = vbYellow -未給定 9. Case 5 -未給定 10. BackColor = vbWhiteflag = 0-未給定 11. End Select -未給定

30、 12. End Sub -未給定 問(wèn)題 1 得 0 分,滿分 20 分   從鍵盤(pán)輸入m、n的值(m>0,n>0),求 y = m! + n!, 并在窗體上顯示結(jié)果。要求用函數(shù)實(shí)現(xiàn)求階乘的功能。 正確答案所選答案1. Public Function fact(k As Integer) As Long -未給定 2. Dim i As Integerfact = 1 -未給定 3. For i = 1 To k -未給定 4. fact = fact * i -未給定 5. Next i -未給定 6. End FunctionPrivate Sub Form

31、_Click()-未給定 7. Dim m As Integer, n As Integer -未給定 8. Dom = InputBox("") -未給定 9. n = InputBox("")Loop Until m > 0 And n > 0-未給定 10. Print fact(m) + fact(n) -未給定 11. End Sub -未給定   問(wèn)題 2 得 0 分,滿分 20 分   兩質(zhì)數(shù)的差為2,稱(chēng)此兩質(zhì)數(shù)為質(zhì)數(shù)對(duì),設(shè)計(jì)一個(gè)程序找出100以?xún)?nèi)的質(zhì)數(shù)對(duì),并在窗體上成對(duì)顯示結(jié)果。要求質(zhì)數(shù)的判斷用自

32、定義函數(shù)完成。  正確答案所選答案1. Private Function prime(ByVal k As Integer) As Boolean -未給定 2. Dim i As IntegerIf k < 2 Then -未給定 3. prime = False -未給定 4. Else -未給定 5. For i = 2 To Sqr(k) -未給定 6. If k Mod i = 0 Then Exit For -未給定 7. Next iIf i > Sqr(k) Then prime = True Else prime = False-未給定 8. End I

33、f -未給定 9. End FunctionPrivate Sub Form_Click()-未給定 10. Dim n As Integer -未給定 11. For n = 3 To 100 Step 2 -未給定 12. If prime(n) And prime(n + 2) Then Print n; n + 2 -未給定 13. Next n -未給定 14. End Sub -未給定   問(wèn)題 3 得 0 分,滿分 20 分   輸入n后,再輸入n個(gè)數(shù)a1 ,a2 ,.,an ,按照下列公式計(jì)算s的值并顯示。 編寫(xiě)事件過(guò)程Command1_

34、Click(),計(jì)算s值,其中 v 值要求調(diào)用函數(shù)過(guò)程 f 來(lái)完成。已知求v值的函數(shù)過(guò)程 f程序如下。Private Function f (x() As Single, n As Integer) as single   Dim i As Integer   For i = 1 To n f = f + x(i)   Next i   f = f / nEnd Function 正確答案所選答案1. Private Sub Command1_Click() -未給定 2. Dim a() As Sing

35、le, n As Integer, s As SingleDim v As Single, i As Integer-未給定 3. n = InputBox("請(qǐng)輸入n的值")ReDim a(n)-未給定 4. For i = 1 To n -未給定 5. a(i) = InputBox("") -未給定 6. Next iv = f(a, n)-未給定 7. For i = 1 To n -未給定 8. s = s + ( a(i) - v ) 2 -未給定 9. Next i -未給定 10. s = Sqr(s) / n -未給定 11. Prin

36、t s -未給定 12. End Sub -未給定   問(wèn)題 4 得 0 分,滿分 20 分   編制函數(shù)過(guò)程求二維數(shù)組a(n,n)的對(duì)角線上各元素的和。  正確答案所選答案1. Public Function ff(a() As Single, n As Integer) As Single -未給定 2. Dim i As Integer, j As Integerff = 0-未給定 3. For i = 1 To nFor j = 1 To n-未給定 4. If i = j Or i + j = n + 1 Then ff = ff + a(i

37、, j) -未給定 5. Next j -未給定 6. Next i -未給定 7. End Function -未給定   問(wèn)題 5 得 0 分,滿分 20 分   編寫(xiě)一子過(guò)程,將數(shù)組a(n, n)轉(zhuǎn)置。  正確答案所選答案1. Public Sub ff(a() As Single, n As Integer) -未給定 2. Dim i As Integer, j As Integer, t As Single -未給定 3. For i = 2 To nFor j = 1 To i-1-未給定 4. t = a(i, j) -未給定 5. a(

38、i, j) = a(j, i) -未給定 6. a(j, i) = t -未給定 7. Next j -未給定 8. Next i -未給定 9. End Function -未給定  問(wèn)題 1 得 0 分,滿分 20 分   編寫(xiě)Sub過(guò)程求一元二次方程的實(shí)數(shù)解,并通過(guò)事件過(guò)程調(diào)用它。 Private Sub Command1_Click()   Dim a As Double, b As Double, c As Double, y1 As Double, y2 As Double   a = 3: b = 1: c =

39、 5   If root(a, b, c, y1, y2) Then Print y1, y2   Else Print "方程無(wú)實(shí)數(shù)解!"   End IfEnd Sub 正確答案所選答案1. Private Function root(ByVal a As Double, ByVal b As Double, ByVal c As Double, x1 As Double, x2 As Double) As Boolean -未給定 2. Dim d As Double -未給定 3. d

40、= b * b - 4 * a * c -未給定 4. If d < 0 Then -未給定 5. root = False -未給定 6. Else -未給定 7. root = Truex1 = (-b + Sqr(d) / (2 * a): x2 = (-b - Sqr(d) / (2 * a)-未給定 8. End If -未給定 9. End Function -未給定   問(wèn)題 2 得 0 分,滿分 20 分   產(chǎn)生10個(gè)30,50的隨機(jī)整數(shù),并按從小到大的順序打印出來(lái),要求調(diào)用Swap子過(guò)程實(shí)現(xiàn)兩個(gè)數(shù)交換。 Public Sub S

41、wap(a As Integer, b As Integer)   Dim temp As Integer   temp = a :  a = b :  b = tempEnd Sub 正確答案所選答案1. Private Sub form_click() -未給定 2. Dim a(10) As Integer, i As Integer, j As Integer -未給定 3. For i = 1 To 10 -未給定 4. a(i)= Int(Rnd * 21) + 30Next i-未給定 5. For i = 1 To 9

42、 -未給定 6. For j = i + 1 To 10 -未給定 7. If a(i) > a(j) Then -未給定 8. Call Swap(a(i), a(j) -未給定 9. End If -未給定 10. Next j -未給定 11. Form1.Print a(i);Next i-未給定 12. Form1.print a(10)-未給定 13. End Sub -未給定   問(wèn)題 3 得 0 分,滿分 20 分   求下面表達(dá)式的值,并在窗體上輸出。要求m與n的值在窗體單擊事件中用Inputbox()函數(shù)輸入,且同為正整數(shù),m&

43、gt;n。通過(guò)函數(shù)過(guò)程實(shí)現(xiàn)求階乘的功能。 Private Sub Form_Click()    Dim m As Integer, n As Integer   Do m = InputBox("m=", "m>0,m必須大于n")n = InputBox("n=", "n>0")   Loop While m <= n Or m < 0 Or n < 0   Print f

44、act(m) / fact(n) / fact(m - n)End Sub 正確答案所選答案1. Private Function fact(ByVal k As Integer) As Long -未給定 2. Dim i As Integer -未給定 3. fact = 1 -未給定 4. For i = 2 To k -未給定 5. fact = fact * i -未給定 6. Next i -未給定 7. End Function -未給定   問(wèn)題 4 得 0 分,滿分 20 分   驗(yàn)證哥德巴赫猜想大于6的偶數(shù)可以分解為兩個(gè)素?cái)?shù)之和,調(diào)用函數(shù)過(guò)程實(shí)

45、現(xiàn)判斷任一正整數(shù)是不是素?cái)?shù)。 Private Function prime(ByVal n As Integer) As Boolean   Dim i As Integer   prime = True     For i = 2 To Sqr(n)If n Mod i = 0 Then prime = False: Exit For   Next iEnd Function 正確答案所選答案1. Private Sub Form_Click() -未給定 2. Dim n1 As Integ

46、er, n2 As Integer, n As Integer -未給定 3. Don = InputBox("輸入一個(gè)大于6 的偶數(shù)")-未給定 4. Loop While n <= 6 Or n Mod 2 <> 0 -未給定 5. For n1 = 3 To n / 2 Step 2 -未給定 6. n2 = n - n1 -未給定 7. If prime(n1) And prime(n2) Then -未給定 8. Print n; "=" n1; "+" n2Exit For-未給定 9. End If -

47、未給定 10. Next n1 -未給定 11. End Sub -未給定   問(wèn)題 5 得 0 分,滿分 20 分   編制通用函數(shù)過(guò)程fsum,計(jì)算Single類(lèi)型一維數(shù)組所有元素的和。  正確答案所選答案1. Private Function fsum(a() As Single, n As Integer) As Single -未給定 2. Dim i As Integer -未給定 3. For i = 1 To n -未給定 4. fsum = fsum + a(i) -未給定 5. Next i -未給定 6. End Function

48、-未給定 問(wèn)題 1 得 0 分,滿分 20 分   驗(yàn)證哥德巴赫猜想大于6的偶數(shù)可以分解為兩個(gè)素?cái)?shù)之和,調(diào)用函數(shù)過(guò)程實(shí)現(xiàn)判斷任一正整數(shù)是不是素?cái)?shù)。 Private Function prime(ByVal n As Integer) As Boolean   Dim i As Integer   prime = True     For i = 2 To Sqr(n)If n Mod i = 0 Then prime = False: Exit For   Next iEnd Func

49、tion 正確答案所選答案1. Private Sub Form_Click() -未給定 2. Dim n1 As Integer, n2 As Integer, n As Integer -未給定 3. Don = InputBox("輸入一個(gè)大于6 的偶數(shù)")-未給定 4. Loop While n <= 6 Or n Mod 2 <> 0 -未給定 5. For n1 = 3 To n / 2 Step 2 -未給定 6. n2 = n - n1 -未給定 7. If prime(n1) And prime(n2) Then -未給定 8. Pri

50、nt n; "=" n1; "+" n2Exit For-未給定 9. End If -未給定 10. Next n1 -未給定 11. End Sub -未給定   問(wèn)題 2 得 0 分,滿分 20 分   輸入n后,再輸入n個(gè)數(shù)a1 ,a2 ,.,an ,按照下列公式計(jì)算s的值并顯示。 編寫(xiě)事件過(guò)程Command1_Click(),計(jì)算s值,其中 v 值要求調(diào)用函數(shù)過(guò)程 f 來(lái)完成。已知求v值的函數(shù)過(guò)程 f程序如下。Private Function f (x() As Single, n As Integer)

51、 as single   Dim i As Integer   For i = 1 To n f = f + x(i)   Next i   f = f / nEnd Function 正確答案所選答案1. Private Sub Command1_Click() -未給定 2. Dim a() As Single, n As Integer, s As SingleDim v As Single, i As Integer-未給定 3. n = InputBox("請(qǐng)輸入n的值")R

52、eDim a(n)-未給定 4. For i = 1 To n -未給定 5. a(i) = InputBox("") -未給定 6. Next iv = f(a, n)-未給定 7. For i = 1 To n -未給定 8. s = s + ( a(i) - v ) 2 -未給定 9. Next i -未給定 10. s = Sqr(s) / n -未給定 11. Print s -未給定 12. End Sub -未給定   問(wèn)題 3 得 0 分,滿分 20 分   編寫(xiě)子過(guò)程DeleStr(s1,s2),將字符串s1中出現(xiàn)的字符串s2刪去,結(jié)果仍存放在s1中。例如:s1=“1234567ABCDEF456789”, s2=“4567”結(jié)果:s1=“123ABCDEF89”正確答案所選答案1. Private Function delestr( s1 As String, s2 As String ) As String -未給定 2. Dim s As String, m%, n%, k%m = Len( s2 )-未給定 3. Do While InStr( s1, s2 ) > 0 -未給定 4. k = Len( s1 )n = I

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論