Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, x If x <= 2 Then ans = 1 If x > 2 Then ans = x - 1 Print #2, ans 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 Input #1, n If n > 1 Then a = n - 1 If n = 1 Then a = 1 Print #2, a 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 Input #1, n If n = 1 Then t = 1 Else t = n - 1 End If Print #2, t Close #2 Close #1 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 Input #1, x If (x <= 2) And (x = 0) Then ans = 1 If x > 2 Then ans = x - 1 Print #2, ans 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 Input #1, a If a = 0 Then Print #2, 0 ElseIf a < 2 Then Print #2, 1 Else Print #2, a - 1 End If Close End End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Input #1, n
Close #1
x = 0
If n < 2 Or n = 2 Then x = 1
If n > 2 Then x = n - 1
Open App.Path & "\out.txt" For Output As #1
Print #1, x
Close #1
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
Input #1, x
If x <= 2 Then ans = 1
If x > 2 Then ans = x - 1
Print #2, ans
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
Input #1, n
If n > 1 Then a = n - 1
If n = 1 Then a = 1
Print #2, a
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
Input #1, n
If n = 1 Then
t = 1
Else
t = n - 1
End If
Print #2, t
Close #2
Close #1
End
End Sub
以上程式正確:)
回覆刪除另外如果輸入n範圍是0<=n<32768的話要檢查0喔(邊界值)
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x
If (x <= 2) And (x = 0) Then ans = 1
If x > 2 Then ans = x - 1
Print #2, ans
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
Input #1, a
If a = 0 Then
Print #2, 0
ElseIf a < 2 Then
Print #2, 1
Else
Print #2, a - 1
End If
Close
End
End Sub