问题
I am new to programming in general and I am trying to learn the basics of it. Could someone explain me the concept of Pseudo code. I have already done some research but an additional help would be great. As an example, what would pseudo code for making a peanut butter and jelly sandwich would look like?
-Thank you.
回答1:
Pseudo code is meant to describe and describe the flow, structure and logical statements of a program or and algorithm (in most cases only parts of it) in a way that is easy to understand without needing to analyze actual code, and can also be understood by those without any programming knowledge.
Pseudo code can either consist of real code-like examples, or just pure text.
An example of a pseudo code for making a PBJ could look something like this:
MakePBJRoutine(input: peanut butter, jelly, bottom bread, top bread)
Begin routine:
Take bottom bread.
Spread peanut butter on bottom bread.
Spread jelly on bottom bread.
If want more jelly:
Spread jelly on bottom bread.
Place top bread slice on bottom bread
Return finished sandwich
End routine
Meanwhile, it could also look like this.
makePBJroutine(input: P, J, TB, BB; Out: PBJ) {
BB <- P;
BB <- J;
If(BB.J < PreferredJellyAmountConstant){
BB <- J;
}
PBJ <- (BB <- TB);
Return PBJ;
}
来源:https://stackoverflow.com/questions/41516963/pseudo-code-example