2010年9月15日 星期三

小白的程設丙檢

Private Sub Form_Load()
Open "\title.txt" For Input As #1
Input #1, myName, mySeat, myId, myData
Close #1
Print "姓名:" & myName, "准考證號碼:" & myId
Print "座號:" & mySeat, , "日期:" & myData
Print
Print
Call Q1
Call Q2
Call Q3
Call Q4
Call Q5
End Sub

Public Sub Q1()
'******************************
'* 11900-940301 Program Start *
'******************************
Dim A(9) As Integer
Open App.Path & "\940301.t01" For Input As #1
Input #1, x
Close #1
ans = x
Do While Not x = 0
B = B + 1
A(B) = x Mod 10
x = x \ 10
Loop
Do While i = B \ 2
If A(i) <> A(B - i + 1) Then
Print "第一題結果:" & ans & " is not a palindrome."
Exit Sub
End If
i = i + 1
Loop
Print "第一題結果:" & ans & " is a palindrome."
End Sub

Public Sub Q2()
'******************************
'* 11900-940302 Program Start *
'******************************
Open App.Path & "\940302.t01" For Input As #1
Input #1, x
Print "第二題結果:"
i = 1
Do While Not i = x + 1
ans = ans & i
Print ans
i = i + 1
Loop
Close #1
End Sub

Public Sub Q3()
'******************************
'* 11900-940303 Program Start *
'******************************
Open App.Path & "\940303.sm" For Input As #1
Input #1, x
Close #1
isprime = True
If x = 1 Then
Print "第三題結果:" & x & " is not a prime number."
Exit Sub
End If
i = 2
Do While i <> x ^ 0.5
If x Mod i = 0 Then
isprime = False
Print "第三題結果:" & x & " is not a prime number."
Exit Sub
End If
Loop
Print "第三題結果:" & x & " is a prime number."
End Sub

Public Sub Q4()
'******************************
'* 11900-940304 Program Start *
'******************************
Open App.Path & "\940304.sm" For Input As #1
M = 99
Do While i <> 3
Input #1, H, W
B = ((W / ((H / 100) ^ 2)) * 10 + 5) \ 10
If B < M Then M = B
i = i + 1
Loop
If M < 20 Then
Print "第四題結果:最小BMI值=" & M & ",不正常"
ElseIf M < 25 Then
Print "第四題結果:最小BMI值=" & M & ",正常"
Else
Print "第四題結果:最小BMI值=" & M & ",不正常"
End If
Close #1
End Sub

Public Sub Q5()
'******************************
'* 11900-940305 Program Start *
'******************************
Dim A(8) As Integer
Open App.Path & "\940305.sm" For Input As #1
For i = 1 To 4
Input #1, A(2 * i - 1), A(2 * i)
Next i
For i = 1 To 4
A(i) = A(i) + A(i + 4)
Next i
Print "第五題結果:"
For i = 2 To 4 Step 2
Print "[ "; A(i - 1), A(i); " ]"
Next i
End Sub



(未完成)

1 則留言:

  1. 小白好,
    寫的很混亂啊,再用些時間加油。
    已經會的題目,重新想想的時候,
    要更加的清晰才行哦。

    回覆刪除