版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、第57题 (1.0分) 题号:465'-'【程序改错】'-'题目:用InputBox函数输入一个字符串,编写程序按与' 输入的字符相反的次序用Msgbox函数输出这个字' 符串。如输入字符串为"abcdefgh",则输出为"h' gfedcba",输出效果如图1。'-Option ExplicitPrivate Sub Command1_Click() Dim pristr As String, outstr As String Dim i As Integer pristr = Input
2、Box("please input a string") '*FOUND* For i = 0 To Len(pristr) '*FOUND* outstr = outstr + Mid(pristr, Len(pristr) - i) Next i '*FOUND* MsgBox outstr, , "The Output Result "End Sub答案:=(答案1)=For i = 0 To Len(pristr) - 1=或=For i = 0 To -1+Len(pristr)=(答案2)=outstr = outst
3、r + Mid(pristr, Len(pristr) - i, 1)=或=outstr = Mid(pristr, Len(pristr) - i, 1)+outstr=(答案3)=MsgBox outstr, vbQuestion, "The Output Result "第59题 (1.0分) 题号:147'-'【程序改错】'-'题目:下面的程序用来产生并输出图示的杨辉三角。' 1' 1 1' 1 2 1' 1 3 3 1' 1 4 6 4 1' 1 5 10 10 5 1'-Op
4、tion ExplicitPublic Sub readin(a() As Integer, n As Integer) Dim i, j As Integer For i = 1 To n'*FOUND* a(i, n) = 1 a(i, 1) = 1 Next i For i = 3 To n'*FOUND* For j = 2 To n a(i, j) = a(i - 1, j) + a(i - 1, j - 1) Next j Next iEnd SubPublic Sub printf(a() As Integer, n As Integer) Dim i, j As
5、 Integer For i = 1 To n'*FOUND* For j = 1 To n Print Tab(5 * j + 10); a(i, j); Next j Print Next i PrintEnd SubPrivate Sub Form_Click() Dim x(10, 10) As Integer Call readin(x(), 6) Call printf(x(), 6)End Sub答案:=(答案1)=a(i, i) = 1=(答案2)=For j = 2 To i - 1=或=For j = 2 To -1 + i=(答案3)=For j = 1 To i
6、第60题 (1.0分) 题号:146'-'【程序改错】'-'题目:用辗转相除法求两个整数的最大公约数。'-Option ExplicitFunction gcd(ByVal m As Integer, ByVal n As Integer) As Integer Dim r As Integer r = m Mod n Do While r <> 0'*FOUND* n = m n = r r = m Mod n Loop'*FOUND* gcd = rEnd FunctionPrivate Sub Form_Click()
7、Dim a As Integer, b As Integer, c As Integer a = InputBox("输入一个整数") b = InputBox("输入一个整数") a = Val(a) b = Val(b)'*FOUND* Call gcd(a, b) Print a, b, cEnd Sub答案:=(答案1)=m = n=(答案2)=gcd = n=(答案3)=c = gcd(a, b)第65题 (1.0分) 题号:492'-'【程序改错】'-'题目:输入两个正整数m和n,求其最大公约数。
8、9;-Option ExplicitPrivate Sub Form_Click() Dim m As Integer, n As Integer, r As Integer m = InputBox("输入m的值:") n = InputBox("输入n的值:") Do While n <> 0 '*FOUND* r = m / n m = n '*FOUND* n = m Loop '*FOUND* Print "两数的最大公因子为:" nEnd Sub答案:=(答案1)=r = m Mod n
9、=(答案2)=n = r=(答案3)=Print "两数的最大公因子为:" m第66题 (1.0分) 题号:467'-'【程序改错】'-'题目:从计算机输入三个数 , 找出中间数'-Option ExplicitPrivate Sub FindMidNum() Dim x As Integer, y As Integer, z As Integer, A As Integer x = InputBox("PLEASE INPUT THE FIRST NUMBER") y = InputBox("PLEAS
10、E INPUT THE SECOND NUMBER") z = InputBox("PLESSE INPUT THE THIRD NUMBER") '*FOUND* If x > y Then A = x x = y y = A End If '*FOUND* If y = z Then Print y '*FOUND* ElseIf x = z Then Print z Else Print x End IfEnd SubPrivate Sub Form_Click() FindMidNumEnd Sub答案:=(答案1)=If x
11、 < y Then=或=If y > x Then=(答案2)=If y >= z Then=或=If z <= y Then=(答案3)=ElseIf x >= z Then=或=ElseIf z <= x Then第70题 (1.0分) 题号:142'-'【程序改错】'-'题目:程序功能根据输入的学习成绩,分别显示优秀' (90分以上), 良好(75分以上),及格(60分以上)' 不及格四个等级.'-Option ExplicitPrivate Sub Form_Click()ClsDim i As
12、 Integeri = InputBox("请输入学习成绩")Select Case i'*FOUND* Case 0 < i < 100 MsgBox "成绩应该在0-100之间"""'*FOUND* Case 90 Print "优秀" Case 75 To 89 Print "良好" Case 60 To 74 Print "及格" '*FOUND* Case MsgBox "不及格", vbCriticalEnd
13、 SelectEnd Sub答案:=(答案1)=Case is>100 ,is<0 =或= case is<0 ,is>100=(答案2)=Case 90 to 100=(答案3)=Case else第71题 (1.0分) 题号:473'-'【程序改错】'-'题目:下列程序进行-n阶乘运算,当阶乘的值超过-21147483648 溢出报错,并将结果输出为-1。'-Option Explicit'*FOUND*Private Function jc(ByVal n As Integer) As Integer Dim I A
14、s Integer Dim result As Long result = 1 I = 1 Do While I <= n If result < 2114748348 / I Then '*FOUND* result = result I = I + 1 Else lblerr.Caption = "溢出" '*FOUND* jc = -I Exit Function End If Loop jc = -resultEnd FunctionPrivate Sub Form_Click() MsgBox jc(3)End Sub答案:=(答案1)
15、=Private Function jc(ByVal n As Integer) As Long=(答案2)=result = result * I=或=result = I * result=(答案3)=jc = -1第72题 (1.0分) 题号:145'-'【程序改错】'-'题目:该程序的功能是求出100到200之间的全部素数,' 并且按每行4个、每个数据之间有10个空格的格' 式输出。'-Option ExplicitPrivate Sub Form_Click() Dim k As Integer, i As Integer, j
16、 As Integer k = 0 For i = 100 To 200'*FOUND* For j = 1 To i - 1 If i Mod j = 0 Then Exit For Next j If j = i Then'*FOUND* Print i; Tab(10); k = k + 1'*FOUND* If k Mod 5 = 0 Then Print ; End If Next iEnd Sub答案:=(答案1)=For j = 2 To i - 1=或=For j = 2 To -1 + i=(答案2)=Print i; Space(10);=或=Pri
17、nt i; Spc(10);=(答案3)=If k Mod 4 = 0 Then Print=或=If 0 = k Mod 4 Then Print=或=if k/4 = k 4 then Print=或=if k4 = k/4 then Print=或=if k/4 = int(k/4) then Print第73题 (1.0分) 题号:132'-'【程序改错】'-'题目:求s=2!+4!+6!+8!,阶乘的计算用Function过程' fact实现'-Option ExplicitPrivate Sub Form_Click()Dim i A
18、s Integer, s As Long'*FOUND*For i = 2 To 8 s = s + fact(i)Next iPrint sEnd Sub'*FOUND*Public Function fact()Dim t As LongDim i As Integert = 1For i = 1 To nt = t * iNext i'*FOUND*fact = iEnd Function答案:=(答案1)=For i = 2 To 8 Step 2=(答案2)=Public Function fact(ByVal n As Integer)=或=Public F
19、unction fact(n As Integer)=或=Public Function fact(n%)=或=Public Function fact(n)=或=Public Function fact(ByVal n%)=或=Public Function fact(ByVal n)=(答案3)=fact = t第76题 (1.0分) 题号:479'-'【程序改错】'-'题目:下面的程序用“冒泡”法完成数组a中的10个整数' 按升序排列,请修正程序中错误。'-Option ExplicitPrivate Sub Command1_Click(
20、) Dim a Dim i As Integer, j As Integer, a1 As Integer a = Array(-2, 5, 24, 58, 43, -10, 87, 75, 27, 83) For i = 1 To 9 '*FOUND* For j = i To 9 '*FOUND* If a(j) >= a(i) Then a1 = a(i) a(i) = a(j) '*FOUND* a(j) = a(i) End If Next j Next i For i = 0 To 9 Print a(i) Next iEnd Sub答案:=(答案1)
21、=For j = i + 1 To 9=或=For j = 1 + i To 9=(答案2)=If a(i) >= a(j) Then=(答案3)=a(j) = a1第77题 (1.0分) 题号:490'-'【程序改错】'-'题目:输入一个字符串,将所有的小写字母都转换为大写字母。'-Option ExplicitPrivate Sub Form_Click() Dim s1 As String, s2 As String, i As Integer, t As String s1 = InputBox("输入字符串,#号结束"
22、) i = 1 '*FOUND* s1 = Mid(s1, i, 1) While t <> "#" '*FOUND* If t >= "a" And t <= "z" Then t = Chr(Asc(t) - 30) s2 = s2 + t i = i + 1 t = Mid(s1, i, 1) Wend '*FOUND* Print "新字符串为:" s1End Sub答案:=(答案1)=t = Mid(s1, i, 1)=(答案2)=If t >= &q
23、uot;a" And t <= "z" Then t = Chr(Asc(t) - 32)=(答案3)=Print "新字符串为:" s2第79题 (1.0分) 题号:487'-'【程序改错】'-'题目:设窗体中有图片框Pic1,现要求在其中绘制10个同心圆,' 然后将此图以Test.BMP作文件名存入磁盘。'-Option ExplicitPrivate Sub Command1_Click() Dim X As Integer Dim Y As Integer Dim I As Inte
24、ger Dim rad(9) As Integer X = Pic1.ScaleWidth / 2 Y = Pic1.ScaleHeight / 2 '*FOUND* For I = 1 To 9 rad(I) = 500 * Rnd Next I I = 9 '*FOUND* Do Until I < 1 Pic1.Circle (X, Y), rad(I), RGB(256 * Rnd, 256 * Rnd, 256 * Rnd) '*FOUND* I = I + 1 Loop SavePicture Pic1.Image, "Test.BMP&qu
25、ot;End Sub答案:=(答案1)=for i=0 to 9 =或= for i=0 to 9 step 1=(答案2)=Do Until I < 0 =或= do until 0>i=(答案3)=I = I - 1 =或= i=-1+i第80题 (1.0分) 题号:460'-'【程序改错】'-'题目:已知C的公式表示如下:' n!' C=-' (n-m)!*m! '函数过程fac( )求k!函数,在Fomr_Click事件中完成运算,'请修正程序中错误。'-Option ExplicitPriva
26、te Function fac(k As Integer) As Single Dim x As Single, j As Integer '*FOUND* x = 0 For j = 1 To k '*FOUND* x = x j Next j fac = xEnd FunctionPrivate Sub Form_Click() Dim C As Single Dim m As Integer, n As Integer m = Val(InputBox("请输入一个整数(m):") n = Val(InputBox("请输入一个整数(n):") '*FOUND* C = fac(n) / fac(n - m) * fac(m) Print "
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 个人财产抵押借款简易协议文本版A版
- 二零二四全新石灰石环保综合利用合同3篇
- 2024版特种设备吊装运输合同3篇
- 个人房产买卖规范协议2024版A版
- 2024年04月中国建设银行北京市分行度社会招考专业人才笔试历年参考题库附带答案详解
- 2025年农业科技推广合同会签纪要3篇
- 2024版轮胎承包合同协议书
- 二零二五年度物流并购保密及市场共享协议2篇
- 专业节电器产品销售协议规范2024版A版
- 2024年03月贵州贵州银行六盘水分行招考笔试历年参考题库附带答案详解
- GB/T 12914-2008纸和纸板抗张强度的测定
- GB/T 1185-2006光学零件表面疵病
- ps6000自动化系统用户操作及问题处理培训
- 家庭教养方式问卷(含评分标准)
- 城市轨道交通安全管理课件(完整版)
- 线缆包覆挤塑模设计和原理
- TSG ZF001-2006 安全阀安全技术监察规程
- 部编版二年级语文下册《蜘蛛开店》
- 锅炉升降平台管理
- 200m3╱h净化水处理站设计方案
- 个体化健康教育记录表格模板1
评论
0/150
提交评论