所以这次的问题是关于收费账户的验证。基本上,我们必须用伪代码设计一个程序,其中用户输入一个帐号,程序通过将其与我们要放入数组中的列表进行比较来验证它。数字应该存储在数组中,我们需要使用顺序搜索算法来定位用户输入的数字。如果数字在数组中,程序会显示一条消息,表明它是有效的。如果不是,则显示无效。主模块有一个需求,函数是TicketValid。我想知道我的伪代码是否正确。谢谢!
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