发布网友 发布时间:1天前
共2个回答
热心网友 时间:5小时前
你想一想,你的交换部分循环从1开始到4
而循环内是:a(i + 1) = a(i)
是把1里的数据存放到2里,那么2的数据是不是给覆盖了呢?
应该
For i= 5 to 2 step -1
a(i) = a(i-1)
next i
a(1)=x
for i=1 to 5
print a(i)
next i
热心网友 时间:5小时前
Me.Cls
Dim a(1 To 5) As Integer
Dim x%, tmp%
Print "交换前:"
Print
For i = 1 To 5
a(i) = Int(Rnd * 100)
Print a(i);
Next i
Print
Print "交换后:"
Print
x = a(5)
For i = 5 To 1 Step -1
If i - 1 >= 1 Then
a(i) = a(i - 1)
End If
Next
a(1) = x
For i = 1 To 5
Print a(i);
Next