字體:小 中 大 | |
|
|
2010/02/19 21:52:18瀏覽1911|回應0|推薦1 | |
第一題解題程式 FOR迴圈版 Private Sub cmd_no1_Click()'************************** '*119-940301 Program Start* '************************** Open "A:\940301.SM" For Input As #1 Input #1, n Close #1 n2 = n For i = 1 To 99 S = S & (n2 Mod 10) n2 = (n2 - (n2 Mod 10)) / 10 If n2 = 0 Then Exit For Next If n / S = 1 Then S = n & " is a palindrome." Else S = n & " is not a palindrome." End If txt_no1.Text = "第一題結果:" & S End Sub DO WHILE 前測版 Private Sub cmd_no1_Click() '************************** '*119-940301 Program Start* '************************** Open "A:\940301.SM" For Input As #1 Input #1, n Close #1 n2 = n Do While n2 > 0 S = S & (n2 Mod 10) n2 = (n2 - (n2 Mod 10)) / 10 Loop If n / S = 1 Then S = n & " is a palindrome." Else S = n & " is not a palindrome." End If Txt_no1.Text = "第一題結果:" & S End Sub DO WHILE 後測版 Private Sub Cmd_no1_Click() '************************** '*119-940301 Program Start* '************************** Open "c:\940301.SM" For Input As #1 Input #1, n Close #1 n2 = n Do S = S & (n2 Mod 10) n2 = (n2 - (n2 Mod 10)) / 10 Loop While n2 > 0 If n / S = 1 Then S = n & " is a palindrome." Else S = n & " is not a palindrome." End If txt_no1.Text = "第一題結果:" & S End Sub 執行畫面 |
|
( 休閒生活|網路生活 ) |