網路城邦
上一篇 回創作列表 下一篇   字體:
【電腦軟體設計】電腦軟體設計-丙級-術科測驗1站-第1題
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

執行畫面


( 休閒生活網路生活 )
回應 推薦文章 列印 加入我的文摘
上一篇 回創作列表 下一篇

引用
引用網址:https://classic-blog.udn.com/article/trackback.jsp?uid=zdzo&aid=2740022