Flowchart symbols and flowchart examples

Source: Internet
Author: User

Describes common flowchart symbols and flowchart examples.
In this chapterAlgorithmThe flowchart 1-2 is shown. The flowchart 1-3 of the algorithm in Example 1-2 is shown in this chapter.
In the flowchart, the process line on the left of the judgment box indicates the process when the judgment condition is true, and the process line on the right indicates the process when the condition is false, sometimes "true", "false", "T", "F", "Y", and "N" are marked on the top of the left and right flow lines"


It is also stipulated that when the flow line is from bottom up or from right to left, an arrow must be included. In addition, no arrow is drawn, and the flow line is always from top down or from left to right.

2. Structured description of the Algorithm
In earlier non-structured languages, there were go to statements, which allowed Program Directly jump from one place to another.
The advantage of doing so is that Program The design is very convenient and flexible, reducing manual complexity, but its shortcomings are also very prominent. A lot of Jump statements make Program The process is very complex, difficult to understand, difficult to verify Program If there is a mistake, it is even more difficult to make the mistake. The chaos and complexity expressed by this transfer flow chart is exactly in the software crisis. Program A vivid illustration of the personnel situation. Structured Program Design is to clarify this mess.
After research, we found that any complex algorithm can be composed of three basic structures: sequential structure, selection (Branch) structure, and cyclic structure. Therefore, when we construct an algorithm, these three basic structures are also used as "building units" and comply with the specifications of the three basic structures. The basic structures can be parallel and can contain each other, but cannot be crossed, direct transfer from one structure to another is not allowed. Because the entire algorithm is composed of three basic structures, just like the one built by a module, the structure is clear, correctness verification is easy, and error correction is easy. This method is a structured method. Follow this method Program The design is structured. Program Design.
Correspondingly, as long as three basic structures are specified Flowchart You can draw a flowchart of any algorithm.
(1) Ordered Structure
The ordered structure is a simple linear structure. The boxes are executed in order. The basic form of the flowchart 1-4 is shown in the statement
The execution sequence is a → B → C.
(2) Select (Branch) Structure
This structure is used to determine a given condition. When the condition is true or false, the content of different boxes is executed. There are two basic shapes: 1-5 a) and B. Figure 1-5 a) the execution sequence is: execute a when the condition is true; otherwise execute B; Fig 1-5 B) the execution sequence is: execute a when the condition is true, otherwise, do nothing.

(3) Loop Structure
The loop structure has two basic forms: a while loop and a do-while loop.
A. While Type Loop
1-6.
The execution sequence is as follows: when the condition is true, A is repeatedly executed. Once the condition is false, the loop jumps out and the statement after the loop is tight is executed.
B. Do-while Type Loop
1-7.

The execution sequence is: execute a first, and then judge the condition. When the condition is true, A is always executed cyclically. Once the condition is false, the loop ends and the next statement is executed after the loop is tight.
In Figure 1-6 and Figure 1-7, A is called a cyclic body and a condition is called a cyclic control condition. Note that:
1) in the loop body, the value to be judged by the condition must be modified, so that after a finite loop, the loop can
End, I = I-1 in 1-3.
2) When the loop body in a Type Loop may not be executed at once, and until the Type Loop is executed at least once.
3) the type-to-type cycle can be easily converted into a type-to-type cycle, while the type-to-type cycle may not be converted into a type-to-type cycle.
For example, Figure 1-7 can be converted to Figure 1-8.

7. algorithm described by N-S Diagram
The N-S diagram is another algorithm representation proposed by I. nassi and B. shneiderman of the US, based on the following:
Since any algorithm is composed of the three structures described above, the flow lines between the basic structures are redundant. Therefore, the n-s graph is also a Structured description method of the algorithm.
In the n-s diagram, an algorithm is a large rectangular box that contains several basic boxes. The N-S diagram of the three basic structures is described as follows:
1. Ordered Structure
1-9. The execution sequence is a and B.
2. Select Structure
The N-S Diagram corresponding to Figure 1-5 is 1-1 0. Figure 1-10 a) execute a when the condition is true and B when the condition is false. Figure 1-1 0
If Condition B is true, execute a. If it is false, do nothing.

3. Loop Structure
1) as shown in Figure 1-11 of the while loop, when the condition is true, the loop body a is cyclically executed until the condition is false.
2) In the n-s diagram of the do-while loop 1-1 2, the loop body a is executed cyclically until the condition is false.
In this chapter, the N-S Diagram 1-1 3 in 1-1, and the N-S Diagram 1-1 4 in 1-2. The N-S diagram is more intuitive and concise than the flowchart.

8. Describe the algorithm using pad Graphs
Problem Analysis divisor (PAD) is a graphical representation of algorithms widely used in software development in recent years. Compared with the preceding flowchart and n-s diagram, flow charts and n-s charts are top-down Sequential descriptions. In addition to top-down, pad charts also expand from left to right. Therefore, if the flow chart and n-s chart are one-dimensional algorithm descriptions, the pad chart is two-dimensional. It can display the layered structure of the algorithm, which is more intuitive and easy to understand.
Below are several basic forms of pad graphs:
1. Sequence Structure:
1-1 5.
2. Select Structure
(1) Select a single branch. If the condition is true, execute a, 1-16 ).
(2) select 1-16 B for the two branches. If the condition is true, execute a. If the condition is false, execute B.
(3) multi-branch selection, 1-16 C). When I = I1, execute a, I = I2, execute B, I = I3, and execute C, run D when I = I4.

3. Loop Structure
1-1 7. Figure 1-17 A) is a while loop, and Figure 1-17 B) is a do-while loop.

In this chapter, for example 1. 1, PA d 1-1 8, for example 1-2, PA d 1-1 9

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.