Dim a(10) As Integer ‘將陣列定義為全域性變數
Private Sub Command1_Click()
Dim i As Integer
Dim n As Integer
For i = 0 To 9
a(i) = Int(Rnd() * 100)
Print a(i);
Next i
Print
n = InputBox("請輸入N的值:")
Call Fan(0, n - 1)
Call Fan(n, 9)
Call Fan(0, 9)
End Sub
Sub Fan(i1, i2 As Integer) ‘將陣列中i1到i2之間的元素反轉放置
While i1 < i2
t = a(i1): a(i1) = a(i2): a(i2) = t
i1 = i1 + 1: i2 = i2 - 1
Wend
Dim a(10) As Integer ‘將陣列定義為全域性變數
Private Sub Command1_Click()
Dim i As Integer
Dim n As Integer
For i = 0 To 9
a(i) = Int(Rnd() * 100)
Print a(i);
Next i
Print
n = InputBox("請輸入N的值:")
Call Fan(0, n - 1)
Call Fan(n, 9)
Call Fan(0, 9)
For i = 0 To 9
Print a(i);
Next i
Print
End Sub
Sub Fan(i1, i2 As Integer) ‘將陣列中i1到i2之間的元素反轉放置
While i1 < i2
t = a(i1): a(i1) = a(i2): a(i2) = t
i1 = i1 + 1: i2 = i2 - 1
Wend
End Sub