Private Sub Command1_Click()
Dim a(4) As Integer
a(0) = 1
a(1) = 3
a(2) = 5
a(3) = 7
a(4) = 11
Dim b() As Integer
ReDim b(0)
Dim i As Integer
Dim j As Integer
For i = 0 To 4
ReDim Preserve b(j)
b(j) = a(i)
If a(i) <= 5 Then
ReDim Preserve b(j + 1)
b(j + 1) = a(i) + 10
j = j + 1
End If
j = j + 1
Next
Dim str As StringFor i = 0 To UBound(b)
str = str & "b[" & i & "] = " & b(i) & vbCrLf
Next
MsgBox str
End Sub
Dim a(4) As Integer
a(0) = 1
a(1) = 3
a(2) = 5
a(3) = 7
a(4) = 11
Dim b() As Integer
ReDim b(0)
Dim i As Integer
Dim j As Integer
For i = 0 To 4
ReDim Preserve b(j)
b(j) = a(i)
If a(i) <= 5 Then
ReDim Preserve b(j + 1)
b(j + 1) = a(i) + 10
j = j + 1
End If
j = j + 1
Next
Dim str As StringFor i = 0 To UBound(b)
str = str & "b[" & i & "] = " & b(i) & vbCrLf
Next
MsgBox str
End Sub
ReDim Preserve b(j + 1)
在c#如何写义?
如输入一组数如a1={1,3,5,7,11)
则输出a1={1,11,3,13,5,15,7,11}