An outline of a program, written in a form that can easily be converted into real programming statements. For example, the pseudocode for a bubble sortroutine might be written:
while not at end of list
compare adjacent elements
if second is greater than first
switch them
get next two elements
if elements were switched
repeat for entire list
compare adjacent elements
if second is greater than first
switch them
get next two elements
if elements were switched
repeat for entire list
Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules. It is simply one step - an important one - in producing the final code. The benefit of pseudocode is that it enables theprogrammer to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language. In fact, you can write pseudocode without even knowing what programming language you will use for the final implementation.
Pseudocode Example
This is the pseudocode for a Game of Monopoly, including one person's move as a procedure:
Main Procedure Monopoly_Game
Hand out each player's initial money.
Decide which player goes first.
Repeat
Call Procedure Monopoly_Move for next player.
Decide if this player must drop out.
Until all players except one have dropped out.
Declare the surviving player to be the winner.
Procedure Monopoly_Move
Begin one's move.
Throw the dice.
Move the number of spaces on the board shown on the dice.
If the token landed on "Go to Jail,"
then go there immediately.
Else if the token landed on "Chance" or "Community Chest,"
then draw a card and follow its instructions.
Else
follow the usual rules for the square (buying property,
paying rent, collecting $200 for passing "Go", etc.).
End one's move.
http://users.ece.utexas.edu/~valvano/assmbly/intro.htm
CITATION :
CITATION :
No comments:
Post a Comment