




已阅读5页,还剩49页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
问题 1 得 2.22 分,满分 20 分 编写一子过程,将数组a(n, 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. a(j, i) = t -未给定 7. Next j -未给定 8. Next i -未给定 9. End Function -未给定 问题 2 得 0 分,满分 20 分 求下面表达式的值,并在窗体上输出。要求m与n的值在窗体单击事件中用Inputbox()函数输入,且同为正整数,mn。通过函数过程实现求阶乘的功能。Private Sub Form_Click() Dim m As Integer, n As Integer Dom = InputBox(m=, m0,m必须大于n)n = InputBox(n=, n0) 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 = 1 -未给定 4. For i = 2 To k -未给定 5. fact = fact * i -未给定 6. Next i -未给定 7. End Function -未给定 问题 3 得 0 分,满分 20 分 编写一个将一维数组倒置存放的子过程,并编写简单事件验证子过程的正确性。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 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 -未给定 问题 4 得 0 分,满分 20 分 输入n后,再输入n个数a1 ,a2 ,.,an ,按照下列公式计算s的值并显示。编写事件过程Command1_Click(),计算s值,其中 v 值要求调用函数过程 f 来完成。已知求v值的函数过程 f程序如下。Private Function f (x() As Single, n As Integer) as single Dim i As Integer For i = 1 To nf = 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(请输入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. Print s -未给定 12. End Sub -未给定 问题 5 得 0 分,满分 20 分 编写Sub过程求一元二次方程的实数解,并通过事件过程调用它。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 = 5 If root(a, b, c, y1, y2) ThenPrint y1, y2 ElsePrint 方程无实数解! 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 = 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 -未给定 问题 1 得 0 分,满分 20 分 编写一子过程,将数组a(n, 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(i, j) = a(j, i) -未给定 6. a(j, i) = t -未给定 7. Next j -未给定 8. Next i -未给定 9. End Function -未给定 问题 2 得 0 分,满分 20 分 两质数的差为2,称此两质数为质数对,设计一个程序找出100以内的质数对,并在窗体上成对显示结果。要求质数的判断用自定义函数完成。 正确答案所选答案1. Private Function prime(ByVal k As Integer) As Boolean -未给定 2. Dim i As IntegerIf k 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 -未给定 问题 3 得 0 分,满分 20 分 编写子过程,将某数组中元素按值从大到小排序,并在窗体的单击事件中,编写简单程序验算其正确性。Private Sub Form_click() Dim x(10) As Single, i As Integer Print 排序前: For i = 1 To 10x(i) = InputBox(b( + Str(i) + )=)Print x(i); Next i Print Call sort(x(), 10) Print 排序后: For i = 1 To 10Print 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 -未给定 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 -未给定 问题 4 得 0 分,满分 20 分 编写Sub过程求一元二次方程的实数解,并通过事件过程调用它。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 = 5 If root(a, b, c, y1, y2) ThenPrint y1, y2 ElsePrint 方程无实数解! 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 = 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 -未给定 问题 5 得 0 分,满分 20 分 编写一个将一维数组倒置存放的子过程,并编写简单事件验证子过程的正确性。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 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 -未给定 问题 1 得 0 分,满分 20 分 编写一个将一维数组倒置存放的子过程,并编写简单事件验证子过程的正确性。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 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 -未给定 问题 2 得 0 分,满分 20 分 验证哥德巴赫猜想大于6的偶数可以分解为两个素数之和,调用函数过程实现判断任一正整数是不是素数。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 Integer, n2 As Integer, n As Integer -未给定 3. Don = InputBox(输入一个大于6 的偶数)-未给定 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 -未给定 10. Next n1 -未给定 11. End Sub -未给定 问题 3 得 0 分,满分 20 分 编写函数过程,计算某一维数组的最大值,并在窗体的单击事件中,验算其正确性。Private Sub Form_Click() Dim a(10) As Integer For i = 1 To 10a(i) = Int(Rnd * 90) + 10Print a(i); Next i Print Print 最大值是:; fmax(a(), 10)End Sub 正确答案所选答案1. Private Function fmax(x() As Integer, ByVal n As Byte) As Integer -未给定 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 -未给定 问题 4 得 0 分,满分 20 分 从1到10000中找出这样的数,该数各个位的数字的阶乘相加之和等于该数,并将结果输出。要求调用fact函数过程计算阶乘。Private Function fact(ByVal k As Integer) As Long Dim i As Integer fact = 1 For i = 2 To kfact = 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 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 -未给定 问题 5 得 0 分,满分 20 分 编程,使窗体的背景色在四种颜色间变换。第一次单击窗体是红色;第二次单击窗体是绿色;第三次单击窗体是蓝色;第四次单击窗体是黄色;第五次又重新开始。要求其中使用静态变量。 正确答案所选答案1. Private Sub 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 -未给定 12. End Sub -未给定 问题 1 得 0 分,满分 20 分 从键盘输入m、n的值(m0,n0),求 y = m! + 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_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 -未给定 问题 2 得 0 分,满分 20 分 两质数的差为2,称此两质数为质数对,设计一个程序找出100以内的质数对,并在窗体上成对显示结果。要求质数的判断用自定义函数完成。 正确答案所选答案1. Private Function prime(ByVal k As Integer) As Boolean -未给定 2. Dim i As IntegerIf k 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 -未给定 问题 3 得 0 分,满分 20 分 输入n后,再输入n个数a1 ,a2 ,.,an ,按照下列公式计算s的值并显示。编写事件过程Command1_Click(),计算s值,其中 v 值要求调用函数过程 f 来完成。已知求v值的函数过程 f程序如下。Private Function f (x() As Single, n As Integer) as single Dim i As Integer For i = 1 To nf = 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(请输入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. Print s -未给定 12. End Sub -未给定 问题 4 得 0 分,满分 20 分 编制函数过程求二维数组a(n,n)的对角线上各元素的和。 正确答案所选答案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, j) -未给定 5. Next j -未给定 6. Next i -未给定 7. End Function -未给定 问题 5 得 0 分,满分 20 分 编写一子过程,将数组a(n, 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(i, j) = a(j, i) -未给定 6. a(j, i) = t -未给定 7. Next j -未给定 8. Next i -未给定 9. End Function -未给定 问题 1 得 0 分,满分 20 分 编写Sub过程求一元二次方程的实数解,并通过事件过程调用它。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 = 5 If root(a, b, c, y1, y2) ThenPrint y1, y2 ElsePrint 方程无实数解! 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 = b * b - 4 * a * c -未给定 4. If d 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.printa(10)-未给定 13. End Sub -未给定 问题 3 得 0 分,满分 20 分 求下面表达式的值,并在窗体上输出。要求m与n的值在窗体单击事件中用Inputbox()函数输入,且同为正整数,mn。通过函数过程实现求阶乘的功能。Private Sub Form_Click() Dim m As Integer, n As Integer Dom = InputBox(m=, m0,m必须大于n)n = InputBox(n=, n0) 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 = 1 -未给定 4. For i = 2 To k -未给定 5. fact = fact * i -未给定 6. Next i -未给定 7. End Function -未给定 问题 4 得 0 分,满分 20 分 验证哥德巴赫猜想大于6的偶数可以分解为两个素数之和,调用函数过程实现判断任一正整数是不是素数。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 Integer, n2 As Integer, n As Integer -未给定 3. Don = InputBox(输入一个大于6 的偶数)-未给定 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 -未给定 10. Next n1 -未给定 11. End Sub -未给定 问题 5 得 0 分,满分 20 分 编制通用函数过程fsum,计算Single类型一维数组所有元素的和。 正确答案所选答案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 -未给定 问题 1 得 0 分,满分 20 分 验证哥德巴赫猜想大于6的偶数可以分解为两个素数之和,调用函数过程实现判断任一正整数是不是素数。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 Integer, n2 As Integer, n As Integer -未给定 3. Don = InputBox(输入一个大于6 的偶数)-未给定 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 -未给定 10. Next n1 -未给定 11. End Sub -未给定 问题 2 得 0 分,满分 20 分 输入n后,再输入n个数a1 ,a2 ,.,an ,按照下列公式计算s的值并显示。编写事件过程Command1_Click(),计算s值,其中 v 值要求调用函数过程 f 来完成。已知求v值的函数过程 f程序如下。Private Function f (x() As Single, n As Integer) as single Dim i As Integer For i = 1 To nf = 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(请输入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. Print s -未给定 12. End Sub -未给定 问题 3 得 0 分,满分 20 分 编写子过程DeleStr(s1,s2),将字符串s1中出现的字符串s2删去,结果仍存放在s1中。例如:s1=“1234567ABCDEF456789”, s2=“4567”结果: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 = InStr( s1, s2 )-未给定 5. s = Left( s1, n-1 ) + Right( s1, k - m - n + 1 )s1 = s-未给定 6. Loop -未给定 7. delest
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度高品质住宅小区车库车位租赁及增值服务合同
- 2025年智能家居系统安装与交付验收服务合同
- 2025年物联网设备安全监测与维护服务合同
- 2025年度校园体育设施深度清洁与维护服务合同
- 2025年北京XX教育机构信托资金应收账款贴现借款合同
- 2025年度环保型特种材料研发与国内销售代理合同
- 2025年新能源汽车关键零部件集中采购合作协议
- 2025年食品生产企业员工健康与安全教育培训服务合同
- 2025年航天器制造技术专利独占许可及转让合同
- 2025年电子商务平台下划线图标设计制作与授权许可合同
- 人教版四年级数学上册单元课程纲要
- 金属矿石购销合同模板
- DL∕T 1052-2016 电力节能技术监督导则
- 肌肉注射完整版本
- DL5190.5-2019电力建设施工技术规范第5部分:管道及系统
- 应急照明、疏散指示系统施工方案
- 物流服务方案与实施方案(2篇)
- QBT 2959-2008 钢板网行业标准
- DB32T3795-2020企事业单位和工业园区突发环境事件应急预案编制导则
- 《国际中文教育概论》课件全套 第1-12章 从对外汉语教学到国际中文教育- 国际中文教育前瞻
- 2024国际贸易重点总结
评论
0/150
提交评论