2012年11月5日 星期一

一堆石頭

可愛的潘潘有著一堆石頭,每顆石頭上面都有一個正整數編號。接著,她又利用複製機器把每顆石頭都複製了兩個,而編號當然跟原來那個一樣。

可是有一天,她不小心掉了一顆石頭,現在她想要找出她掉的那一顆石頭的編號。

輸入說明 :
只有一筆測資給你她現在所擁有的石頭的編號,用空格分開。

當然,個數一定是三的倍數減一個。 

輸出說明 :
輸出她掉的那一顆石頭的編號。


範例輸入 :

9 8 6 9 8 2 3 5 2 1 6 8 1 5 1 2 3 3 5 9
範例輸出 :

6

4 則留言:

  1. Dim dataa As String
    Dim countt(9999) As Integer
    Private Sub Form_Load()
    Open App.Path & "\in.txt" For Input As #1
    Open App.Path & "\out.txt" For Output As #2
    Line Input #1, dataa
    mycount = Split(dataa, " ")

    For i = 0 To UBound(mycount)
    countt(mycount(i)) = countt(mycount(i)) + 1
    Next

    For ii = 1 To 9
    If countt(ii) = 2 Then Print #2, ii
    Next

    Close #2
    Close #1
    End Sub

    回覆刪除
  2. 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 n(19), i As Integer
    i = 0
    Do Until EOF(1)
    Input #1, n(i)
    i = i + 1
    Loop
    For j = 0 To UBound(n)
    'MsgBox n(j)
    For k = 0 To UBound(n) - 1
    If n(k) > n(k + 1) Then
    a = n(k)
    n(k) = n(k + 1)
    n(k + 1) = a
    End If
    Next
    Next j
    For p = 0 To 17 Step 3
    If n(p) <> n(p + 2) Then
    Print #2, n(p)
    Exit For
    Else
    End If
    Next
    If n(17) <> n(19) Then Print #2, n(19)
    Close #2
    Close #1
    End
    End Sub

    回覆刪除
  3. Private Sub Form_Load()
    Me.Hide
    Open App.Path & "\in.txt" For Input As #1
    Open App.Path & "\out.txt" For Output As #2
    Line Input #1, x
    m = Split(x, " ")
    For i = 0 To UBound(m)
    b = 1
    For j = 0 To UBound(m)
    If m(i) = m(j) And m(i) <> 0 And i <> j Then b = b + 1: m(j) = 0
    Next
    If b Mod 3 = 2 Then Print #2, m(i)
    Next
    Close
    Close
    End
    End Sub

    回覆刪除