Created
April 22, 2022 15:12
-
-
Save yycking/b861a40da8d62e6be8b4af5e9587b306 to your computer and use it in GitHub Desktop.
寫一程式仿金融卡提款,從鍵盤輸入帳號與密碼,若正確就顯示帳號與密碼正確可進行提款(預設帳號為你的學號,密碼為IMD12345),若錯誤則顯示帳號與密碼錯誤,還有幾次輸入機會(共有六次輸入之機會)。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- set_prolog_flag(verbose, silent). | |
:- initialization(main). | |
帳號(學號). 密碼("IMD12345"). | |
登入(Account, Password):- | |
帳號(Account), 密碼(Password), | |
write("帳號與密碼正確可進行提款"), nl. | |
登入:- | |
write("輸入帳號"), nl, | |
read(Account), | |
write("輸入密碼"), nl, | |
read(Password), | |
登入(Account, Password). | |
登入([]):- | |
登入; | |
write("請聯絡客服中心,歡迎再度光臨。"), nl. | |
登入(Try):- | |
登入; | |
[Count | Chance ] = Try, | |
write("帳號與密碼錯誤,還有"), write(Count), write("次輸入機會"), nl, | |
登入(Chance). | |
main:- | |
登入([五, 四, 三, 二, 一]), | |
halt. |
Author
yycking
commented
Apr 22, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment