內容 :
可愛的潘潘有著一堆石頭,每顆石頭上面都有一個正整數編號。接著,她又利用複製機器把每顆石頭都複製了兩個,而編號當然跟原來那個一樣。
可是有一天,她不小心掉了一顆石頭,現在她想要找出她掉的那一顆石頭的編號。
輸入說明 :
只有一筆測資給你她現在所擁有的石頭的編號,用空格分開。
當然,個數一定是三的倍數減一個。
輸出說明 :
輸出她掉的那一顆石頭的編號。
範例輸入 :
9 8 6 9 8 2 3 5 2 1 6 8 1 5 1 2 3 3 5 9
範例輸出 :
6
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Dim a(100) As Integer
Do While Not EOF(1)
Input #1, n
a(n) = a(n) + 1
Loop
For i = 1 To 100
If a(i) = 2 Then Print #2, i
Next
Close
Close
End
End Sub
Private Sub Form_Load()
回覆刪除Dim X(10) As Integer
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
X(N) = X(N) + 1
Loop
For i = 0 To 10
If X(i) = 2 Then Print #2, i
Next i
Close #2
Close #1
End
End Sub
arro,佑好,
回覆刪除程式正確。
繼續努力哦。
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\out.txt" For Output As #2
Open App.Path & "\in.txt" For Input As #1
'Do While Not EOF(1)
' Input #1, n
' m = n & " "
'Loop
Line Input #1, m
x = Split(m)
For i = 0 To UBound(x)
s = 0
For j = i + 1 To UBound(x)
If x(i) <> "" And x(i) = x(j) Then
s = s + 1
x(j) = ""
End If
Next j
If s = 1 Then Print #2, x(i)
Next i
Close #1
Close #2
End
End Sub
緣尉好,
回覆刪除程式ok, 但是,可以也試試arro的方式。