Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, c For ii = 1 To c Input #1, x ReDim a(1) As Integer n = 0 For i = 1 To Len(x) a(n) = a(n) + Mid(x, i, 1) n = Abs(n - 1) Next i Print k = Abs(a(0) - a(1)) If k = 0 Or k Mod 11 = 0 Then Print #2, 1 Else Print #2, 0 End If Next ii Close #1 Close #2 End Sub
Dim A(100) As String Private Sub Form_Load() Open App.Path & "/in.txt" For Input As #1 Open App.Path & "/out.txt" For Output As #2 Input #1, x For i = 1 To x Input #1, A(i) q = 0: p = 0 For j = 1 To Len(A(i)) b = Mid(A(i), j, 1) If b Mod 2 = 0 Then p = p + b If b Mod 2 = 1 Then q = q + b Next j If (q - b) Mod 11 = 0 Then Print #2, "1" If (q - b) Mod 11 <> 0 Then Print #2, "0" Next i Close #2 Close #1 End Sub Dim A(100) As String Private Sub Form_Load() Open App.Path & "/in.txt" For Input As #1 Open App.Path & "/out.txt" For Output As #2 Input #1, x For i = 1 To x Input #1, A(i) q = 0: p = 0 For j = 1 To Len(A(i)) b = Mid(A(i), j, 1) If b Mod 2 = 0 Then p = p + b If b Mod 2 = 1 Then q = q + b Next j If (q - b) Mod 11 = 0 Then Print #2, "1" If (q - b) Mod 11 <> 0 Then Print #2, "0" Next i Close #2 Close #1 End Sub
Dim a(100) As Integer Dim b(100) As Integer Dim ans(100) As Integer Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 k = 1 Input #1, n Do While Not EOF(1) Input #1, q For i = 1 To Len(q) Step 2 a(i) = Mid(q, i, 1) sumA = sumA + a(i) Next i For j = 2 To Len(q) Step 2 b(j) = Mid(q, j, 1) sumB = sumB + b(j) Next j If sumA Mod sumB = 0 Then ans(k) = 1 Else ans(k) = 0 End If maxK = k k = k + 1 sumA = 0 sumB = 0 Loop For i = 1 To maxK Print #2, ans(i) Next i Close #2 Close #1 End Sub
Dim q As String Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, x For i = 1 To x ans = 0 Input #1, q e = 1 Do Until q = "" l = Right(q, 1) q = Left(q, Len(q) - 1) If e Mod 2 = 0 Then ans = ans + Val(l) Else ans = ans - Val(l) End If e = e + 1 Loop If Abs(ans) Mod 11 = 0 Then Print #1, 1 Else Print #1, 0 End If Next i Close #2 Close #1 End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, c
For ii = 1 To c
Input #1, x
ReDim a(1) As Integer
n = 0
For i = 1 To Len(x)
a(n) = a(n) + Mid(x, i, 1)
n = Abs(n - 1)
Next i
Print
k = Abs(a(0) - a(1))
If k = 0 Or k Mod 11 = 0 Then
Print #2, 1
Else
Print #2, 0
End If
Next ii
Close #1
Close #2
End Sub
Dim A(100) As String
回覆刪除Private Sub Form_Load()
Open App.Path & "/in.txt" For Input As #1
Open App.Path & "/out.txt" For Output As #2
Input #1, x
For i = 1 To x
Input #1, A(i)
q = 0: p = 0
For j = 1 To Len(A(i))
b = Mid(A(i), j, 1)
If b Mod 2 = 0 Then p = p + b
If b Mod 2 = 1 Then q = q + b
Next j
If (q - b) Mod 11 = 0 Then Print #2, "1"
If (q - b) Mod 11 <> 0 Then Print #2, "0"
Next i
Close #2
Close #1
End Sub
Dim A(100) As String
Private Sub Form_Load()
Open App.Path & "/in.txt" For Input As #1
Open App.Path & "/out.txt" For Output As #2
Input #1, x
For i = 1 To x
Input #1, A(i)
q = 0: p = 0
For j = 1 To Len(A(i))
b = Mid(A(i), j, 1)
If b Mod 2 = 0 Then p = p + b
If b Mod 2 = 1 Then q = q + b
Next j
If (q - b) Mod 11 = 0 Then Print #2, "1"
If (q - b) Mod 11 <> 0 Then Print #2, "0"
Next i
Close #2
Close #1
End Sub
阿瑋、高仔好,
回覆刪除這樣的題目,是滿單純的,如果數學上知道,程式就做得出來。
所以呢,數學還是要加加油哦。
(雖然這題的數學程式很低,但是,也可能出現符合你們數學程式的題目啊)
另外,當題目簡單,一人做出來後,其它人,也要做哦。只要不用copy的,自己打了,
用自己的方式,就算是相似度九成也沒關係。記得,對得起自己就是了。
Dim a(100) As Integer
回覆刪除Dim b(100) As Integer
Dim ans(100) As Integer
Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
k = 1
Input #1, n
Do While Not EOF(1)
Input #1, q
For i = 1 To Len(q) Step 2
a(i) = Mid(q, i, 1)
sumA = sumA + a(i)
Next i
For j = 2 To Len(q) Step 2
b(j) = Mid(q, j, 1)
sumB = sumB + b(j)
Next j
If sumA Mod sumB = 0 Then
ans(k) = 1
Else
ans(k) = 0
End If
maxK = k
k = k + 1
sumA = 0
sumB = 0
Loop
For i = 1 To maxK
Print #2, ans(i)
Next i
Close #2
Close #1
End Sub
小白好,
回覆刪除這題還算和其它人一樣OK, 只是,
1. 題目說最長可能有1000位,請問,這樣讀得進來,放得進字串嗎?
2. 題目並沒有說會有多少組數字,你多用了陣列去存,如果超過你的upper bound 上限,是不是就出錯了呢?
3. 題目說第一個數字是表示有幾組,那就用for 迴圈就好了,while not eof(1),似乎多了些。
4. 競試的題目,暫時可以不用理會「錯誤處理」。(這似乎不是好的習慣,但是,競試的時間有限,各種錯誤的可能狀況,實在是可能多到處理不完,不在時間內比這項猜可能錯的能力。)
5. 續4,不處理錯誤,但是,題目說的,一定要含進去,像這題說的「最高有可能到1000位。」
Dim q As String
回覆刪除Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x
For i = 1 To x
ans = 0
Input #1, q
e = 1
Do Until q = ""
l = Right(q, 1)
q = Left(q, Len(q) - 1)
If e Mod 2 = 0 Then
ans = ans + Val(l)
Else
ans = ans - Val(l)
End If
e = e + 1
Loop
If Abs(ans) Mod 11 = 0 Then
Print #1, 1
Else
Print #1, 0
End If
Next i
Close #2
Close #1
End Sub