Dim mynum, num(), temp 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, mynum If mynum = 0 Then Exit Do ReDim num(mynum) For i = 1 To mynum Input #1, num(i) Next
For ii = 1 To mynum For iii = ii + 1 To mynum If num(ii) > num(iii) Then temp = num(ii) num(ii) = num(iii) num(iii) = temp End If Next Next
For iiii = 1 To mynum Print #2, num(iiii); Next Print #2, Loop Close #2 Close #1
Dim mynum, num(), temp 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, mynum If mynum = 0 Then Exit Do ReDim num(mynum) For i = 1 To mynum Input #1, num(i) Next
For ii = 1 To mynum For iii = ii + 1 To mynum If num(ii) > num(iii) Then temp = num(ii) num(ii) = num(iii) num(iii) = temp End If Next Next
For iiii = 1 To mynum Print #2, num(iiii) & " "; Next Print #2, Loop Close #2 Close #1
Dim a() 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, s ReDim a(s) For i = 1 To s Input #1, a(i) Next If s <> 0 Then For i = 1 To s For j = 1 To s - 1 If a(j) > a(j + 1) Then x = a(j) a(j) = a(j + 1) a(j + 1) = x End If Next Next
For i = 1 To s Print #2, a(i) & " "; Next ElseIf s = 0 Then Exit Do End If Print #2, Loop Close Close End End Sub
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 ' Until s = 0 Input #1, s If s = 0 Then Exit Do 'If s <> 0 Then Line Input #1, x x = Split(x) For k = 0 To UBound(x) For j = k + 1 To UBound(x) If Val(x(k)) > Val(x(j)) Then a = Val(x(k)) x(k) = Val(x(j)) x(j) = a End If Next Next For t = 0 To UBound(x) Print #2, x(t) & Space(1); Next Print #2, "" 'Else 'Exit Do 'End If 'Input #1, s Loop End Close #2 Close #1 End Sub
Dim mynum, num(), temp 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, mynum
If mynum = 0 Then Exit Do
ReDim num(mynum)
For i = 1 To mynum
Input #1, num(i)
Next
For ii = 1 To mynum
For iii = ii + 1 To mynum
If num(ii) > num(iii) Then
temp = num(ii)
num(ii) = num(iii)
num(iii) = temp
End If
Next
Next
For iiii = 1 To mynum
Print #2, num(iiii);
Next
Print #2,
Loop
Close #2
Close #1
End
End Sub
哈囉~把輸出說明看好吧~程式有小錯但不嚴重~不過還是謹慎一點好:)
回覆刪除Dim mynum, num(), temp 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, mynum
If mynum = 0 Then Exit Do
ReDim num(mynum)
For i = 1 To mynum
Input #1, num(i)
Next
For ii = 1 To mynum
For iii = ii + 1 To mynum
If num(ii) > num(iii) Then
temp = num(ii)
num(ii) = num(iii)
num(iii) = temp
End If
Next
Next
For iiii = 1 To mynum
Print #2, num(iiii) & " ";
Next
Print #2,
Loop
Close #2
Close #1
End
End Sub
Dim a()
回覆刪除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, s
ReDim a(s)
For i = 1 To s
Input #1, a(i)
Next
If s <> 0 Then
For i = 1 To s
For j = 1 To s - 1
If a(j) > a(j + 1) Then
x = a(j)
a(j) = a(j + 1)
a(j + 1) = x
End If
Next
Next
For i = 1 To s
Print #2, a(i) & " ";
Next
ElseIf s = 0 Then Exit Do
End If
Print #2,
Loop
Close
Close
End
End Sub
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 ' Until s = 0
Input #1, s
If s = 0 Then Exit Do
'If s <> 0 Then
Line Input #1, x
x = Split(x)
For k = 0 To UBound(x)
For j = k + 1 To UBound(x)
If Val(x(k)) > Val(x(j)) Then
a = Val(x(k))
x(k) = Val(x(j))
x(j) = a
End If
Next
Next
For t = 0 To UBound(x)
Print #2, x(t) & Space(1);
Next
Print #2, ""
'Else
'Exit Do
'End If
'Input #1, s
Loop
End
Close #2
Close #1
End Sub