VB101正副選手考3 (2012.10.29考試)
考試時間:下午1點0分到4點30分。
考完將程式貼在回應,若1個回應太長,貼成2個(或以上),貼錯的,也不要刪掉。
(請只貼上有可能會正確的,寫一半的程式就不用貼上來。)
(單題跑超過10分鐘的程式,也不用貼上來,算跑不出解答的)
(1-4題,不用輸入檔的,請將解答也貼在程式後面,方便熊掌改)
(加油)
---------------------------------------------------------------------------------
1.趣味數字問題1
3888 * 2 = 7776
上式的等號兩邊都有一個四位數,注意左邊的3888的後三位數相同,而右邊的7776卻是前三位數相同。因為發現這兩個數的變化頗具特色(本來是後三位相同,乘以2後卻變成前三位相同),所以這時也突發奇想,問自己這個問題:「上面等式兩邊的四位數,除了原本的3888與7776這一組數,可以構成一組型如(abbb,cccd)的四位數組解之外,是否還有其他的四位數組解呢?」
也就是說,請找出下面包含兩個未知的四位數abbb,cccd的數學式子的解:
abbb *2 = cccd
上面的abbb與cccd加上底線,是強調它們是十進位的寫法。其中,a,c是1~9的正整數,b,d是0~9的整數。為了避免出現像1111×2=2222或3333×2=6666這樣子的例子出現,我們規定a與b不同,且c與d也不同。
請將解答輸出於out1.txt,若無其它解,則寫「無」。
2.趣味的數字問題2
請看第一個式子如下:
當時筆者是將上式寫在一面黑板上,隨後筆者心血來潮,動手把某些數字擦掉,使其成為下式:
此時筆者身旁剛好有一位數學同好,筆者問他:「數字內應該填什麼呢?」,他頗認真的解了起來,解法很不錯。大概看過他所使用解法後,我也獲得了一些想法。而這件事過了幾天後,筆者也自問:「空格裡面的數字,除了原本等號左邊的132與等號右邊的17寫入可以滿足等式之外,是否還可以填上其他不同的數字呢?」
請將解答輸出於out2.txt,若無其它解,則寫「無」。
3.又是質數問題
假設a, b, c, a+b-c, a+c-b, b+c-a, a+b+c,皆為相異正質數,且其中兩數和為1000。求a+b+c的最大可能值是多少?
4.暴力証明題
有個數學証明題,是要証明存在一個3的正整數次方,其十進位展開末3位數為001。
証明的方式當然很數學,這裡請用電腦程式的方式,找出到底是3的n次方的展開末3位數為001。
n的最小值是多少?
5.換牌問題
若
現在有 5張撲克牌,點數分別是 1點至 5點,各張牌的點數都不同,並且
5張牌已依點數由小到大排列。選手若要改變排列順序,只能用「換牌」動作。假設一個「換牌」的動作,可以將順序中的第
1張牌(首牌)與其他牌「交換」位置,形成1個新的牌組順序。我們現在用 1個長度為 5的字串,表示1個牌組順序。例如以字串「12345」,表示這
5張牌現在依其點數由小到大排列。如果我們進行第 1次「換牌」動作,假設將「牌 1」(首牌)與「牌
5」交換,就形成新的牌組順序「52341」。如果要進行第 2次的「換牌」,就將「牌
5」(首牌)與其他牌交換,即可形成下一個牌組順序。現在給一個「目的地牌組順序」,請從牌組順序「12345」開始,用最多
10次的「換牌」動作,最後轉換成「目的地牌組順序」。
輸入說明:第 1行為給定的「目的地牌組順序」字串(長度為5)。
輸出說明:第 1行輸出起始牌組順序「 12345」,最後 1行輸出「目的地牌組順序」。第 2行起依序輸出每次「換牌」後的牌組順序。
輸入檔案 :【檔名:in5.txt】
21534
輸出檔案:【檔名:out5.txt】
12345
32145
42135
52134
12534
21534
6.日期判斷
請選手判斷輸入檔中的 4行文句,是否存在符合條件的「日期字串」。
在
文句中,只可能包括「中文」及「半型數字」,並且不包含任何空白及標點符號。待檢查的「日期字串」格式為「民國yyy年 mm月
dd日」,其中「民國」、「年」、「月」及「日」的順序不可改變。屬於年的「 yyy」部分,合法值是「1~999」,可存在「前置
0」,但其長度僅能是 1、2或 3位數。例如民國 9年,可表現為「民國 9年」、「民國 09年」或「民國
009年」。關於月份部分,合法值是「1~12」,同樣接受「前置 0」,其長度僅能是 1或 2位數。日期部分的範圍是「 1~31」,亦接受「前置
0」,其長度僅能是 1或 2位數。選手應另注意,符合條件的日期值不應超過該年當月份的最大天數,例如某年某月份有
30天,則符合條件的日期值為1~30。
【註 1】西元年 = 民國年 + 1911
【註 2】在本題限制的年份中,若其西元年「可被 400整除」或是「可被 4整除而且不被 100整除」,則當年是閏年,其2月有 29天,否則為 28天。
輸入說明:輸入檔中的第 1~4行,表示待檢查的 4句文句,每行文句均獨立檢查,每句文句不超過 100個字。
輸出說明:依序 4行輸出,分別對應輸入檔第 1~4行文句之檢查結果。若文句中存在符合條件的「日期字串」請輸出「符合」,若不存在時請輸出「不符合」。
輸入檔案 :【檔名:in6.txt】
他的生日是民國 89 年2 月29 日
她的生日是民國 90 月2 年29 日
民國 90 年3 月25 日是他的到職日
民國 90 年25 日3 月是她的到職日
輸出檔案:【檔名:out6.txt】
符合
不符合
符合
不符合
7.樂透電腦選號並排序
樂透號碼由1到49中,選取6個數字為一張彩券。有些人喜歡自己選,有些人喜歡交給電腦選號。請寫個程式,幫買家電腦選號。
由檔案中讀入欲購買的張數,輸出不同號碼組合的彩券,號碼要儘量亂選,不要買家才想買3張,電腦選擇的是
1,2,3,4,5,6
1,2,3,4,5,7
1,2,3,4,5,8
這樣買家會覺得電腦怎麼這麼笨而有抱怨。(雖然說不定這才是第1特獎呢?)
當然,更不能讓買家買到重複組合的彩券。(應該沒有人可以買超過所有組合吧?)
所以,請在輸出之前,將這些彩券排序,每張彩卷的號碼都是由小到大排。
而不同張彩券的排序,請以這些號碼的總和來排,也是由小到大排列。
例如:
輸入檔案:
3
輸出檔案:
3 17 22 29 31 38
2 11 33 39 44 48
15 19 32 35 37 49
8.數字個數拆解
計算二數成績的數字個數:從指定目錄"in.txt"讀取二個四位數正整數,相乘的積,計算該數字0到9的數字個數,輸出至指定目錄"out.txt"。
如1255*2100=2635500,結果有0有2個,2有1個,3有1個,5有2個,6有1個。其他個有0個,不用顯示。
輸入範例:1255 2100
輸出範例:02 21 31 52 61
9.16進位
讀取一正整數,將它轉為16進位後輸出。
輸入範例:168
輸出範例:A8
10.時針和分針的夾角
在一般的時鐘上通常有兩根指針:時針、分針。請從"in10.txt"讀取時間,回應此十分針和時針的夾角。
(所有角度接取最小度數 Ex:9:00是90度,不是-90度也不是270度)
時間格式: H:M
1 <=H<=12
00<=M<=59
0:00代表輸入結束
輸入範例:
12:00
9:00
8:10
0:00
輸出範例:
0.000
90.000
175.000
1.
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\out.txt" For Output As #1
For i = 1000 To 4999
a = Mid(i, 1, 1)
a1 = Mid(i, 2, 1)
a2 = Mid(i, 3, 1)
a3 = Mid(i, 4, 1)
b = i * 2
c = Mid(b, 4, 1)
b1 = Mid(b, 1, 1)
b2 = Mid(b, 2, 1)
b3 = Mid(b, 3, 1)
If a1 = a2 And a2 = a3 And a <> a1 Then
If b1 = b2 And b2 = b3 And c <> b1 And i <> 3888 Then Print #1, i & " " & b
End If
Next
Close
End
End Sub
答案:
1666 3332
2777 5554
4999 9998
2.
Dim ch As Boolean
Private Sub Form_Load()
Me.Hide
Open App.Path & "\out.txt" For Output As #1
For i = 101 To 999
a = i ^ 2
If Right(a, 3) = "424" Then
ch = True
If Len(a) - 3 = 2 And i <> 132 Then
Print #1, i & " " & Left(a, 2)
ch = False
End If
End If
Next
If ch = True Then Print #1, "無"
Close
End
End Sub
答案: 無
3.
Dim ch As Boolean
Private Sub Form_Load()
Me.Hide
Open App.Path & "\out.txt" For Output As #1
For i = 2 To 1000
ch = True
For j = 2 To i \ 2
If i Mod j = 0 Then ch = False: Exit For
Next
If ch = True Then List1.AddItem i
Next
For i = 0 To List1.ListCount - 1
For j = 0 To List1.ListCount - 1
If i <> j Then
If Val(List1.List(i)) + Val(List1.List(j)) = 1000 Then List2.AddItem List1.List(i) & " " & List1.List(j)
End If
Next
Next
For i = 0 To List1.ListCount - 1
ch = True
For j = 0 To List2.ListCount - 1
a = Split(List2.List(j))
If Val(a(0)) <> Val(List1.List(i)) And Val(a(1)) <> Val(List1.List(i)) Then
b = Val(a(0)) + Val(a(1)) + Val(List1.List(i))
c = Val(a(0)) - Val(a(1)) + Val(List1.List(i))
d = Val(a(0)) + Val(a(1)) - Val(List1.List(i))
e = Val(a(1)) - Val(a(0)) + Val(List1.List(i))
If b <> c And b <> d And b <> e Then
If c <> d And c <> e Then
If d <> e Then
If abc(b) = False Then Exit For
If abc(c) = False Then Exit For
If abc(d) = False Then Exit For
If abc(d) = False Then Exit For
List3.AddItem Val(a(0)) + Val(a(1)) + Val(List1.List(i))
End If
End If
End If
End If
Next
Next
Print #1, List3.List(List3.ListCount - 1)
Close
End
End Sub
Function abc(n) As Boolean
abc = True
For i = 2 To n \ 2
If n Mod i = 0 Then abc = False
Next
End Function
答案:1997
4.
Dim ch As Boolean
Private Sub Form_Load()
Me.Hide
Open App.Path & "\out.txt" For Output As #1
ch = False
a = 1
b = 0
Do
a = a * 3
b = b + 1
If Len(a) > 3 Then
If Right(a, 3) = "001" Then
Print #1, b
Exit Do
ch = True
Else
a = Right(a, 3)
End If
End If
Loop Until ch = True
Close
End
End Sub
答案:100
5.沒做出來
6.
回覆刪除Private Sub Form_Load()
Me.Hide
Dim ch As Boolean
Open App.Path & "\in6.txt" For Input As #1
Open App.Path & "\out6.txt" For Output As #2
Do While Not EOF(1)
Line Input #1, x
y = "": m = "": d = ""
L = 0
For i = 1 To Len(x)
If Mid(x, i, 2) = "民國" Then
For j = i + 1 To i + 4
If Asc(Mid(x, j, 1)) > 0 Then y = y & Mid(x, j, 1)
Next
L = L + 1
End If
If Mid(x, i, 1) = "年" And L = 1 Then
For j = i + 1 To i + 3
If Asc(Mid(x, j, 1)) > 0 Then m = m & Mid(x, j, 1) Else: Exit For
Next
L = L + 1
End If
If Mid(x, i, 1) = "月" And L = 2 Then
For j = i + 1 To i + 3
If Asc(Mid(x, j, 1)) > 0 Then d = d & Mid(x, j, 1)
Next
L = L + 1
End If
Next
ch = True
If y = "" Or m = "" Or d = "" Then Print #2, "不符合": ch = False
If ch = True Then
If m = "02" Or "2" Then
yy = y + 1911
If yy Mod 400 = 0 Or (yy Mod 4 = 0 And yy Mod 100 <> 0) Then
If d <= 29 Then Print #2, "符合"
Else
If d >= 29 Then Print #2, "不符合"
End If
End If
Select Case Val(m)
Case 1
If Val(d) <= 31 Then Print #2, "符合" Else Print #2, "不符合"
Case 3
If Val(d) <= 31 Then Print #2, "符合" Else Print #2, "不符合"
Case 4
If Val(d) <= 30 Then Print #2, "符合" Else Print #2, "不符合"
Case 5
If Val(d) <= 31 Then Print #2, "符合" Else Print #2, "不符合"
Case 6
If Val(d) <= 30 Then Print #2, "符合" Else Print #2, "不符合"
Case 7
If Val(d) <= 31 Then Print #2, "符合" Else Print #2, "不符合"
Case 8
If Val(d) <= 31 Then Print #2, "符合" Else Print #2, "不符合"
Case 9
If Val(d) <= 30 Then Print #2, "符合" Else Print #2, "不符合"
Case 10
If Val(d) <= 31 Then Print #2, "符合" Else Print #2, "不符合"
Case 11
If Val(d) <= 30 Then Print #2, "符合" Else Print #2, "不符合"
Case 12
If Val(d) <= 31 Then Print #2, "符合" Else Print #2, "不符合"
End Select
End If
Loop
Close
Close
End
End Sub
7.
Private Sub Form_Load()
Me.Hide
Randomize Timer
Dim a(49) As Integer
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
For K = 1 To n
For i = 1 To 49
a(i) = i
Next
For i = 1 To 50
b = Int(Rnd() * 49) + 1
c = Int(Rnd() * 49) + 1
d = a(b): a(b) = a(c): a(c) = d
Next
n1 = Int(Rnd() * 43) + 1
For i = n1 To n1 + 6
List1.AddItem a(i) + 100
Next
c = 0
ans = ""
For i = 0 To List1.ListCount - 1
ans = ans & " " & (List1.List(i) - 100)
c = c + Val(List1.List(i))
Next
List2.AddItem c & " " & ans
List1.Clear
Next
For i = 0 To List2.ListCount - 1
d = Split(List2.List(i), " ")
For j = 1 To UBound(d)
Print #2, d(j) & " ";
Next
Print #2,
Next
Close
Close
End
End Sub
8.
Dim n(9) As Integer
Private Sub Form_Load()
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, X, Y
ans = X * Y
For i = 1 To Len(ans)
For j = 0 To 9
If Val(Mid(ans, i, 1)) = j Then n(j) = n(j) + 1
Next
Next
For i = 0 To 9
If n(i) <> 0 Then Print #2, i & n(i) & " ";
Next
Loop
Close
Close
End
End Sub
9.
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
a = Split("0 1 2 3 4 5 6 7 8 9 A B C D E F", " ")
Do While Not EOF(1)
ans = ""
Input #1, x
Do
b = x Mod 16
x = x \ 16
ans = a(b) & ans
Loop Until x = 0
Print #2, ans
Loop
Close
Close
End
End Sub
10.
Private Sub Form_Load()
Me.Hide
Open App.Path & "\in10.txt" For Input As #1
Open App.Path & "\out10.txt" For Output As #2
a = Split("0 1 2 3 4 5 6 7 8 9 A B C D E F", " ")
Do
Line Input #1, X1
If Len(X1) > 4 Then y = Right(X1, 2): x = Left(X1, 2)
If Len(X1) = 4 Then y = Right(X1, 2): x = Left(X1, 1)
If x = "0" And y = "00" Then Exit Do
ans = (12 - Val(x)) * 30 + (Val(y) / 5) * 30 - (Val(y) / 2)
Print #2, Format(ans, "0.000")
Loop Until x = "0" And y = "00"
Close
Close
End
End Sub
-1-------------------------------------------------
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\out1.txt" For Output As #1
Dim i As Integer
For i = 1000 To 4999
j = i * 2
If Val(Right(i, 3)) Mod 111 = 0 And Left(i, 1) <> Right(i, 1) And Val(Left(j, 3)) Mod 111 = 0 And Left(j, 1) <> Right(j, 1) Then
Print #1, i, j
End If
Next i
Close #1
End
End Sub
out:
1666 3332
2777 5554
3888 7776
4999 9998
-1-------------------------------------------------
-2-------------------------------------------------
Private Sub Form_Load()
Me.Hide
Dim x As Long
Dim t As Boolean
Open App.Path & "\out2.txt" For Output As #1
t = False
For i = 100 To 999
If i = 132 Then i = i + 1
x = i ^ 2
If Right(x, 3) = "424" And x < 99424 Then Print #1, i, Left(x, 2): t = True
Next i
If t = False Then Print #1, "無"
Close #1
End
End Sub
out:
"無"
-2-------------------------------------------------
-7-------------------------------------------------
Private Sub Form_Load()
Me.Hide
Randomize Timer
Dim ans(), ans2()
Open App.Path & "\in7.txt" For Input As #1
Open App.Path & "\out7.txt" For Output As #2
Input #1, n
ReDim ans(n), ans2(n)
For j = 1 To 49
List1.AddItem j + 100
Next j
For i = 1 To 3
For k = 0 To 5
AA:
x = Int(Rnd() * 49)
y = List1.List(x)
If y = 0 Then GoTo AA
List2.AddItem (List1.List(x))
List1.List(x) = 0
Next k
For k = 0 To 5
ans(i) = ans(i) + List2.List(k) - 100
ans2(i) = ans2(i) & " " & List2.List(k) - 100
Next k
List2.Clear
Next i
For i = 1 To n
For j = 1 To n - 1
If ans(j) > ans(j + 1) Then
t = ans(j)
ans(j) = ans(j + 1)
ans(j + 1) = t
End If
Next j
Next i
For i = 1 To n
Print #2, ans(i), ans2(i)
Next i
Close #2
Close #1
End
End Sub
-7-------------------------------------------------
-8-------------------------------------------------
回覆刪除Private Sub Form_Load()
Me.Hide
Dim n As Long
Dim ans(9) As Integer
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, a, b
n = a * b
For j = 1 To Len(a * b)
x = Val(Mid(n, j, 1))
For i = 0 To 9
If x = i Then ans(i) = ans(i) + 1
Next i
Next j
For i = 0 To 9
If ans(i) <> 0 Then Print #2, i & ans(i) & " ";
Next i
Close #2
Close #1
End
End Sub
-8-------------------------------------------------
-9-------------------------------------------------
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
ans = ""
a = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
Do Until Len(n) = 1
ans = a(n Mod 16) & ans
n = n \ 16
Loop
Print #2, ans
Close #2
Close #1
End
End Sub
-9-------------------------------------------------
-10------------------------------------------------
Private Sub Form_Load()
Me.Hide
Dim x As Single
Open App.Path & "\in10.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
n = ""
a = Array("0", "30", "60", "90", "120", "150", "180", "210", "240", "270", "300", "330", "360")
b = 6
Do
Line Input #1, n
If n = "0:00" Then Exit Do
If Len(n) = 5 Then hr = Left(n, 2): mins = Right(n, 2) Else hr = Left(n, 1): mins = Right(n, 2)
x = (mins / 12) * 6
mins = mins * b
ans = a(hr Mod 12) - mins + x
If ans > 180 Then ans = 360 - ans
Print #2, Format(ans, "0.000")
Loop
Close #2
Close #1
End
End Sub
-10------------------------------------------------
-4--------------------------考後更新版
回覆刪除Private Sub Form_Load()
Me.Hide
Dim t As Boolean
Dim x As Double
Open App.Path & "\out.txt" For Output As #1
i = 1
x = 1
t = False
Do Until t = True
x = x * 3
If Right(x, 3) = "001" Then Print #1, i, x: t = True Else x = Right(x, 3)
i = i + 1
Loop
Close #1
End
End Sub
----------------------------------------------------
小冰、哲好,
回覆刪除做得不錯,辛苦了。
第5題的部分,在沒想出其它好方法前,
還是可以用老鼠走迷宮的方式去解。
就是暴力的排列組合吧。
->最近能想到的,都是暴力組合?(汗)
小冰好,
回覆刪除你的第6題中,想得太亂。
統一一下,先設定都符合。
然後開始找出,所有不符合的。
**
就像在找質數,先設定它是質數,
只要找到有可以整除它的數,它才不是質數。
**
2000年2月30日
第五題:
回覆刪除Dim Y(5), M(5), ch(5) As Integer
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
Print #2, "12345"
For i = 1 To 5
k = Mid(x, i, 1)
M(i) = Val(k)
Y(i) = i
ch(i) = 1
Next
For i = 1 To 5
If Y(i) = M(i) Then ch(i) = 0
Next
Do
For i = 2 To 5
If Y(1) = M(1) Then
For j = 2 To 5
If ch(j) <> 0 Then t = Y(1): Y(1) = Y(j): Y(j) = t: GoTo DR
Next
Else
If Y(1) = M(i) And ch(i) <> 0 Then t = Y(1): Y(1) = Y(i): Y(i) = t: ch(i) = 0: Exit For
End If
Next
DR:
For i = 1 To 5
Print #2, Y(i) & "";
Next
Print #2,
For i = 1 To 5
If Y(i) = M(i) Then ch(i) = 0
Next
n = 0
For i = 1 To 5
If ch(i) = 0 Then n = n + 1
Next
Loop Until n = 5
Close
Close
End
End Sub
自己算出來的方法..
回覆刪除題目求a+b+c Max
我假設 c>b>a 又其中兩數合為1000(設a+b)
因為求a+b+c最大值,故只需求c
則c即為 < 1000之最大質數
(兩數合不是其他數字加總是因為不論用除了a,b之外的兩個數相加都會比較小,又因為題目要最大值所以用a+b = 1000)
-3-----------------------------------
Private Sub Form_Load()
Me.Hide
Open App.Path & "\out.txt" For Output As #1
For i = 1000 To 2 Step -1
AA:
For j = 2 To i \ 2
If i Mod j = 0 Then i = i - 1: GoTo AA: Exit For
Next j
Exit For
Next i
Print #2, i + 1000
Close #1
End
End Sub
out:1997
-3------------------------------
哲好,
回覆刪除那麼請問,到底,這a,b,c各是多少?
你只說了其中的c=997。
上一個程式這邊寫錯了.. "Print #2, i + 1000"
回覆刪除應該是 "Print #1, i + 1000"
補上 a,b,c ,a+b+c
Dim sum(1000 / 3)
Private Sub Form_Load()
Me.Hide
Open App.Path & "\out.txt" For Output As #1
Dim a, b, c As Integer
x = 1
For i = 2 To 1000
AA:
For j = 2 To i \ 2
If i Mod j = 0 Then i = i + 1: GoTo AA: Exit For
Next j
If i < 1000 Then List1.AddItem i
Next i
c = Val(List1.List(List1.ListCount - 1))
For i = 0 To List1.ListCount - 1
For j = i + 1 To List1.ListCount
a = Val(List1.List(i)): b = Val(List1.List(j))
If a + b = 1000 Then
If check(a, b, c) = True Then
sum(x) = "a" & a & " " & "b" & b & " " & " c" & c & " " & "a+b+c " & a + b + c
List2.AddItem sum(x)
x = x + 1
End If
End If
Next j
Next i
For k = 1 To x - 1
Print #1, sum(k)
Next k
Close #1
End
End Sub
Function check(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer) As Boolean
Dim t As Boolean
check = False
'a+b-c, a+c-b, b+c-a, a+b+c
If a = b Or a = c Or b = c Then t = False: Exit Function Else t = True
For i = 2 To (a + b - c) \ 2
If (a + b - c) Mod i = 0 Then t = False: Exit Function Else t = True
Next i
For i = 2 To (a + c - b) \ 2
If (a + c - b) Mod i = 0 Then t = False: Exit Function Else t = True
Next i
For i = 2 To (b + c - a) \ 2
If (b + c - a) Mod i = 0 Then t = False: Exit Function Else t = True
Next i
For i = 2 To (a + b + c) \ 2
If (a + b + c) Mod i = 0 Then t = False: Exit Function Else t = True
Next i
check = t
End Function
out:
a23 b977 c997 a+b+c 1997
a137 b863 c997 a+b+c 1997
a347 b653 c997 a+b+c 1997