Private Sub Form_Load() Me.Hide Dim a() As String Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Input #1, n If n = 0 Then Exit Do Line Input #1, x a = Split(x) For i = 0 To UBound(a) For j = 0 To UBound(a) - 1 If Val(a(j)) > Val(a(j + 1)) Then b = a(j) a(j) = a(j + 1) a(j + 1) = b End If Next Next For i = 0 To UBound(a) Print #2, a(i) & " "; Next Print #2, Loop Until n = 0 Close Close End End Sub
Dim ra() As Integer Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do Input #1, n If Val(n) = 0 Then Exit Do ReDim ra(Val(n)) For i = 1 To Val(n) Input #1, r ra(i) = Val(r) Next i For i = 2 To Val(n) If ra(i - 1) < ra(i) Then ra(i - 1) = maxn ra(i - 1) = ra(i) ra(i) = maxn End If Next i For i = val(n) To 1 step -1 Print #2, ra(i); Next i Print #2, Loop Close #2 Close #1 End End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Dim a() As String
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do
Input #1, n
If n = 0 Then Exit Do
Line Input #1, x
a = Split(x)
For i = 0 To UBound(a)
For j = 0 To UBound(a) - 1
If Val(a(j)) > Val(a(j + 1)) Then
b = a(j)
a(j) = a(j + 1)
a(j + 1) = b
End If
Next
Next
For i = 0 To UBound(a)
Print #2, a(i) & " ";
Next
Print #2,
Loop Until n = 0
Close
Close
End
End Sub
作者已經移除這則留言。
回覆刪除Dim ra() As Integer
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do
Input #1, n
If Val(n) = 0 Then Exit Do
ReDim ra(Val(n))
For i = 1 To Val(n)
Input #1, r
ra(i) = Val(r)
Next i
For i = 2 To Val(n)
If ra(i - 1) < ra(i) Then
ra(i - 1) = maxn
ra(i - 1) = ra(i)
ra(i) = maxn
End If
Next i
For i = val(n) To 1 step -1
Print #2, ra(i);
Next i
Print #2,
Loop
Close #2
Close #1
End
End Sub