Private Sub Form_Click()
Form1.AutoRedraw = True
Dim A()
Dim I As Integer, J As Integer, N As Integer
Dim MinG As Integer, MaxG As Integer
A = Array(0, 0, 3, 4, 12, 11, 34, 34, 34, 34)
For I = 0 To UBound(A) - 1
For J = I To UBound(A)
If A(I) > A(J) Then
N = A(I)
A(I) = A(J)
A(J) = N
End If
Next
MinG = 1
MaxG = 1
For I = 1 To UBound(A) - 1
If A(I) = A(0) Then MinG = MinG + 1
If A(I) = A(UBound(A)) Then MaxG = MaxG + 1
Print "陣列為:"
For I = 0 To UBound(A())
Print A(I);
Print
Print "其中最小的元素為:"; A(0); ",個數為:"; MinG
Print "其中最大的元素為:"; A(UBound(A)); ",個數為:"; MaxG
End Sub
已經執行過。
Private Sub Form_Click()
Form1.AutoRedraw = True
Dim A()
Dim I As Integer, J As Integer, N As Integer
Dim MinG As Integer, MaxG As Integer
A = Array(0, 0, 3, 4, 12, 11, 34, 34, 34, 34)
For I = 0 To UBound(A) - 1
For J = I To UBound(A)
If A(I) > A(J) Then
N = A(I)
A(I) = A(J)
A(J) = N
End If
Next
Next
MinG = 1
MaxG = 1
For I = 1 To UBound(A) - 1
If A(I) = A(0) Then MinG = MinG + 1
If A(I) = A(UBound(A)) Then MaxG = MaxG + 1
Next
Print "陣列為:"
For I = 0 To UBound(A())
Print A(I);
Next
Print
Print "其中最小的元素為:"; A(0); ",個數為:"; MinG
Print "其中最大的元素為:"; A(UBound(A)); ",個數為:"; MaxG
End Sub
已經執行過。