Dim mycount, equal1, equal2 As Integer Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As 2 Input #1, mycount For i = 1 To mycount Input #1, num For ii = 1 To Len(num) If Val(Mid(num, ii, 1)) Mod 2 = 1 Then equal1 = equal1 + Val(Mid(num, ii, 1)) If Val(Mid(num, ii, 1)) Mod 2 = 0 Then equal2 = equal2 + Val(Mid(num, ii, 1)) Next If equal1 = equal2 Then Print #2, 1 If Not equal1 = equal2 Then Print #2, 0 equal1 = 0 equal2 = 0 Next Close #2 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, n For i = 1 To n sum1 = 0: sum2 = 0 Input #1, x For m = 1 To Len(x) If m Mod 2 = 0 Then sum1 = sum1 + Val(Mid(x, m, 1)) If m Mod 2 = 1 Then sum2 = sum2 + Val(Mid(x, m, 1)) Next If (sum1 - sum2) Mod 11 = 0 Then Print #2, "1" Else Print #2, "0" Next 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 For j = 1 To n Line Input #1, w lon = Len(w) For i = 1 To lon Step 2 x = Val(Mid(w, i, 1)) + x y = Val(Mid(w, i + 1, 1)) + y Next ans = (x - y) Mod 11 If ans = 0 Then Print #2, "1" Else Print #2, "0" x = 0 y = 0 Next Close #2 Close #1 End End Sub
Dim mycount, equal1, equal2 As Integer
回覆刪除Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As 2
Input #1, mycount
For i = 1 To mycount
Input #1, num
For ii = 1 To Len(num)
If Val(Mid(num, ii, 1)) Mod 2 = 1 Then equal1 = equal1 + Val(Mid(num, ii, 1))
If Val(Mid(num, ii, 1)) Mod 2 = 0 Then equal2 = equal2 + Val(Mid(num, ii, 1))
Next
If equal1 = equal2 Then Print #2, 1
If Not equal1 = equal2 Then Print #2, 0
equal1 = 0
equal2 = 0
Next
Close #2
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, n
For i = 1 To n
sum1 = 0: sum2 = 0
Input #1, x
For m = 1 To Len(x)
If m Mod 2 = 0 Then sum1 = sum1 + Val(Mid(x, m, 1))
If m Mod 2 = 1 Then sum2 = sum2 + Val(Mid(x, m, 1))
Next
If (sum1 - sum2) Mod 11 = 0 Then Print #2, "1" Else Print #2, "0"
Next
Close
Close
End
End Sub
Bob好:)
回覆刪除你的程式少一個判斷喔
查查看11的倍數有什麼特點
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
For j = 1 To n
Line Input #1, w
lon = Len(w)
For i = 1 To lon Step 2
x = Val(Mid(w, i, 1)) + x
y = Val(Mid(w, i + 1, 1)) + y
Next
ans = (x - y) Mod 11
If ans = 0 Then Print #2, "1" Else Print #2, "0"
x = 0
y = 0
Next
Close #2
Close #1
End
End Sub