Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

Pseudo code

Each instruction is on one line (else if excepted) and is not followed by any symbols

Indentation in writing indicates branching structures in a program

Each algorithm begins by describing its inputs and outputs

Each line in the algorithm is numbered, and the line number is used to refer to the steps of the algorithm during the explanation of the algorithm

1. Variable declaration

Arrays and variables can be of the following types:

[Integer, real number, character, bit string, pointer]

Often these types can be determined from the context of the algorithm and need no additional explanation

2. Representation of instructions or subtasks

It can be written

Eg:

“Let x be the largest term in A” => where A is an array

Insert x into L => where L is a linked list

3. Expressions

Arithmetic expressions: arithmetic operators (+, -, *, /, ^)

Logical expressions: Relational operators (=, ≠, <, >, ≤, ≥)

Logical operators (AND, OR, not)

4. Assignment statements

Please b

A: Variable/array item

B: arithmetic expression/logical expression/pointer expression

If ab are both variables/array items, a ←→ B indicates the content exchange of A and B

5. Goto statement

Turns to a statement with the specified label

Eg: Goto label(where label is the GOto label)

6. Branching structure

if i = 10
    then XXX
    else XXX
Copy the code
if i = 10
    then XXX
    elseif i = 9
        then YYY
        YYY
    else XXX
Copy the code

7. Cycle structure

while time < 10
    do XXX
    XXX
    end
Copy the code
for var init to limit by incr do 
    s
end
Copy the code

8. End of program: exit/return

  • An exit statement can be used to terminate the execution of a while or for loop before the usual termination conditions are met, leading to a transition to the statement immediately following the while or for statement that contains exit

  • Return Indicates the focus of an algorithm’s execution (when an undesirable condition is detected)

9, comments,

/ * * /