VB程序改错40题(共15页).doc
《VB程序改错40题(共15页).doc》由会员分享,可在线阅读,更多相关《VB程序改错40题(共15页).doc(15页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
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 = InputBox(please input a string) *FOUND* For i = 0 To Len
2、(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 = outstr + Mid(pristr, Len(pristr) - i, 1)=或=outstr = Mid(pristr, Len(pristr) - i, 1)+outstr=(答案3
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-Option 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* F
4、or 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 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 re
5、adin(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第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*FOU
6、ND* n = m n = r r = m Mod n Loop*FOUND* gcd = rEnd FunctionPrivate Sub Form_Click() 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分) 题号:4
7、92-【程序改错】-题目:输入两个正整数m和n,求其最大公约数。-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=(答案2)=n = r=(答案3)=Print 两数的最
8、大公因子为:; 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(PLEASE INPUT THE SECOND NUMBER) z = InputBox(PLESSE INPUT THE THIRD NUMBER) *FOUND* If x
9、 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 x Then=(答案2)=If y = z Then=或=If z = z Then=或=ElseIf z = x Then第70题 (1.0分) 题号:142-【程序改错】-题目:程序功能根据输入的学习成绩,分别显示优秀 (90分以上),
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VB 程序 改错 40 15
限制150内