VB程序设计多试题及答案解读.doc

  1. 1、本文档共150页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
VB程序设计多试题及答案解读

9、Visual Basic程序改错 程序功能:求s=1+3+5+7+...直到s2000为止。程序中有两行有错误。改正错误,使它能输出正确的结果。 (2025) 平方和 Private Sub Form_Click() Dim i As Integer, s As Long s = 0 : i = 1 Do Until s 2000 s = s + i i = i + 1 Loop Print s End Sub 答案:s2000 ; i+2 程序功能:计算s=2!+4!+8!。程序中有两行有错误。改正错误,使它能输出正确的结果。 (40346) Private Sub Command1_Click() Dim k As Integer, i As Integer Dim s As Long, t As Long s = 0 i = 1 Do While i = 3 t = 1 k = 1 While k = 2*i t = t * k k = k + 1 Wend s = s + t i = i + 1 wend Print s End Sub 答案:k=2^i ; loop 程序功能:计算s=2!+4!+6!+8!。程序中有错误。改正错误,使它能输出正确的结果。 (41066) Private Sub Command1_Click() Dim k As Integer, i As Integer Dim s As Long, t As Long s = 0 : i = 1 Do While i = 4 t = 1 k = 1 While k = 2^i t = t * k k = k + 1 Wend s = s + t i = i + 1 wend Print s End Sub 答案:k=2*i ; loop 程序功能:求200到400间,能被3整除但不能被7整除的数的个数。程序中有两行有错误。改正错误,使它能输出正确的结果。(57) Private Sub Command1_Click() Dim count As Integer Dim x As Integer count = 0 x = 200 While x = 400 If x Mod 3 = 0 or x Mod 7 0 Then count = count + 1 End If x = x + 1 Loop Print count End Sub 答案: and ; wend 程序功能:求1到400间,同时能被3和7整除的数的个数。程序中有两行有错误。改正错误,使它能输出正确的结果。(19) Private Sub Form_Click() Dim count As Integer Dim x As Integer For x = 1 To 400 if mod(x,3)=0 and mod(x,7)=0 then count = count + 1 end if Next count Print count End Sub 答案:x Mod 3 = 0 And x Mod 7= 0; x 程序功能:求能被3整除且至少有一位数字为5的三位数的个数。程序中有两行有错误。改正错误,使它能输出正确的结果。(85) Private Sub Command1_Click() Dim count As Integer Dim a As Integer, b As Integer, c As Integer Dim x As Integer x = 100 do While x = 999 If x Mod 3 = 0 Then a = Int(x / 100) b = Int((x - a * 100) / 10) c = x - a * 100 - b * 10 If a = 5 and b = 5 and c = 5 Then count = count + 1 End If End If x = x + 1 wend Print count End Sub 答案:a = 5 or b = 5 or c = 5 ; loop 程序功能:求三位偶数中,个位数字与十位数字之和除以10所得的余数是百位数字的数的个数。程序中有两行有错误。改正错误,使它能输出正确的结果。(45) 奇数都是45 Private Sub Command1_Click() Dim count As Integer Dim a As Integer, b As Integer, c As Integer Dim x As Integer count = 0 x = 100 While x = 999 a = Int(x / 100

文档评论(0)

shuwkb + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档