そのため、今回の問題は請求先アカウントの検証を扱います。基本的に、ユーザーが口座番号を入力する疑似コードでプログラムを設計する必要があり、プログラムはそれを配列に入れるリストと比較して検証します。数値は配列に格納する必要があり、シーケンシャル検索アルゴリズムを使用して、ユーザーが入力した数値を見つける必要があります。数値が配列内にある場合、プログラムはそれが有効であることを示すメッセージを表示します。そうでない場合は無効と表示されます。メイン モジュールの要件があり、関数は isTicketValid です。私の擬似コードが適切かどうか疑問に思っていました。ありがとう!
Constant Integer SIZE = 18
Declare String account[SIZE] = "5658845", "4520125", "7895122", 8777541", "8451277", "1302850", "8080152", "4562555", "5552012", "5050552", "7825877", "1250255", "1005231", "6545231", "3852085", "7576651", "7881200", "4581002"
Module main()
Display "Please enter your charge account number"
Input account
isValidAccount(account)
Main()
Function Integer isValidAccount(account)
Declare Boolean found
Declare Integer index
Set found = False
Set index = 0
While found == False AND index <= SIZE -1
If account[index] == account Then
Set found = True
Else
Set index = index + 1
End if
End While
If found Then
Display "Your account is valid ", index + 1
Else
Display "Your account is not valid."
End If
End Function