VB高手进来帮个忙,做几道题

来源:百度知道 编辑:UC知道 时间:2024/06/01 12:21:17
程序阅读及程序填空题
1.
[程序说明]有一子过程InsertFun(a%(), y%),它的功能是:把y值插入到有序(升序)数组a中,插入后数组中的数仍然有序。
Private Sub InsertFun(a%(), y%) ' y为要插入的数
Dim j As Integer, i As Integer, n As Integer
j = 1
_______ ' 求数组上界
Do While y > a(j) And j < n ' 查找插入的位置
_______
Loop
For i% = n - 1 To j Step -1 ' 空出要插入的位置
_______
Next i
a(j) = y ' 插入
End Sub
(25.00分)

答:n=ubound (a)' j=j+1
a(i+1)=a(i)

2.
程序
Private Sub Form_Click()
Dim x() As String '定义为可变数组
Dim a$, n%, i%
a$ = "You Win!"
n = Len(a$)
ReDim x(1 To n) '重新定义数组
For i = n To 1 Step -1
x(i) = Mid(a$, i, 1)
Next i
Print a$

第一题你的答案是对的~
2.You Win!
Y o u W i n !
3. 10
10
10
4.How are you!
H o w a r e y o u !
2和4 每一个字符键插入了一个空格,好像百度显示不出来
这样吧,我用“*”代表空格
2)Y*o*u**W*i*n*!
4)H*o*w**a*r*e**y*o*u*!
本身的空格也算一个字符