Dim x() 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 While Not EOF(1) Input #1, N If N = 0 Then Exit Do ReDim x(N) For I = 1 To N Input #1, x(I) Next I
For I = 1 To N - 1 For J = I + 1 To N If x(I) > x(J) Then T = x(I) x(I) = x(J) x(J) = T End If Next J Next I
ans = "" For I = 1 To N ans = ans & x(I) & " " Next I
Dim s 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 While Not EOF(1) Input #1, n If n <> 0 Then Line Input #1, m s = Split(m) Call P End If Loop Close Close End End Sub
Sub P() ans = ""
For j = 0 To UBound(s) For i = 0 To UBound(s) - 1 If Val(s(i)) > Val(s(i + 1)) Then tmp = s(i) s(i) = s(i + 1) s(i + 1) = tmp End If Next Next
For i = 0 To UBound(s) ans = ans & " " & s(i) Next
Dim x()
回覆刪除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 While Not EOF(1)
Input #1, N
If N = 0 Then Exit Do
ReDim x(N)
For I = 1 To N
Input #1, x(I)
Next I
For I = 1 To N - 1
For J = I + 1 To N
If x(I) > x(J) Then
T = x(I)
x(I) = x(J)
x(J) = T
End If
Next J
Next I
ans = ""
For I = 1 To N
ans = ans & x(I) & " "
Next I
Print #2, ans
Loop
Close #2
Close #1
End
End Sub
Dim s
回覆刪除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 While Not EOF(1)
Input #1, n
If n <> 0 Then
Line Input #1, m
s = Split(m)
Call P
End If
Loop
Close
Close
End
End Sub
Sub P()
ans = ""
For j = 0 To UBound(s)
For i = 0 To UBound(s) - 1
If Val(s(i)) > Val(s(i + 1)) Then
tmp = s(i)
s(i) = s(i + 1)
s(i + 1) = tmp
End If
Next
Next
For i = 0 To UBound(s)
ans = ans & " " & s(i)
Next
Print #2, ans
End Sub