vb综合考试试题

Dim x() As String a = \ n = Len(a) ReDim x(1 To n) For i = n To 1 Step -1 x(i) = Mid(a, i, 1) Next I

For i = 1 To n Print x(i); Next i

End Sub

六.程序改错。(本大题共2个小题,每题5分,共10分,每个程序有两处错误,请在答题纸上写出错误行代码和改正后的代码。) 1. 下面的程序是将一个十进制整数转换成二进制数,转换后按位放到一维数组A中,然后输出。如输入一个数据8,将输出1000。程序中有两处错误,请改正 Dim a(10) As Integer

16

Dim k As Integer Dim yu As Integer Dim i As Integer i = 1

k = InputBox(\请输入一个数\Do While k <> 0 yu = k / 2 a(i) = yu k = k \\ 2 i = i + 1 Loop

For yu = i To 1 Step -1 Print a(yu); Next yu

2.陈婷今年17岁,植了3棵树。以后每年多植一棵,问他到什么时候才能累计种到或超过100棵树?

Dim age As Integer, tree As Integer age = 17

17

tree = 3 Do

age = age - 1

tree = tree + age + 14 Loop Until tree = 100

Print \到\岁时种到100棵树\七、程序填空(每空5分,共20分) 1.下列程序功能是:产生10个1~99随机奇数,将其显示出来,用冒泡法按从小到大排列输出:

Option Base 1

private sub form _click()

dim a%(10) i=1

Do while i<=10 x=int(rnd*99+1) if x Mod 2 <>0 then a(i)=x:print a(i); i=i+1

18

end if Loop print for i=1 to 9

for j=1 to ____________ if _______________ then t=a(j):a(j)=a(j+1):a(j+1)=t end if Next j next i for i=1 to 10 print a(i); next i

End sub

2.程序功能:有一分数序列:2/1、 2/3、 5/3 、 8/5 、 13/8、 21/13……求出这个数列的前20项之和。

Private Sub Command1_Click() Dim s as single

19

Dim a as integer, b as integer, c as integer a = 1:b = 2:s=0 For i = 1 To 20 _____________ c = a + b a = b

_____________ Next i Print s End Sub

20

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4