1 / 25
文档名称:

vb程序设计题库.doc

格式:doc   大小:362KB   页数:25页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

vb程序设计题库.doc

上传人:iris028 2021/1/11 文件大小:362 KB

下载得到文件列表

vb程序设计题库.doc

文档介绍

文档介绍:9、Visual Basic程序改错
程序功能:求s=1+3+5+7+...直到s>2000为止。程序中有两行有错误。改正错误,使它能输出正确的结果。 (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
答案:s>2000 ; 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 Integ