求数组的最大值、平均值、能实现将数据升序排列,并且使用InputBox函数插入一个新数据,使数组仍然按升序排列,结果显示在图片框中
Option Base 1
Option Explicit
Dim a(11) As Integer
Private Sub Command1_Click()
Dim i As Integer
picture1.Cls
picture1.Print "产生的一维数组为:"
Randomize
For i = 1 To 10
a(i) = ine(Rnd * 20 + 10)
picture1.Print a(i);
Next i
picture1.Print
End Sub
Private Sub Command2_Click()
Dim max As Integer, p As Integer, i As Integer
max = a(1)
End Sub
Private Sub Command5_Click()
Dim x%, p%, i%
x = Val(InputBox("输入要插入的数据:"))
p = 1
Do While x > a(p) And p <= 10
p = p + 1
Loop
For i = 10 To p Step -1
a(i + 1) = a(i)
Next i
a(p) = x
picture1.Print
picture1.Print "插入后的一维数组为:"
For i = 1 To 11
picture1.Print a(i);
Next i
End Sub