Web Design
Mobile Internet
Brand Design
Innovative
News
Encyclopedias

Three basic structures of the program

Date:2015-06-17 Source: Shangpin China Type: website encyclopedia
Word Size: small   medium   big

It has been proved theoretically that all computers Beijing website construction The program can be described by three basic control structures: sequence, selection and cycle.

1. Sequence structure

The sequence structure is used to represent a sequence of calculation operations that require sequential processing. The calculation process starts from the first operation described to the last operation of the sequence, and is executed sequentially, as shown in Figure 7-3. The sequence structure can also contain other control structures.

2. Select Structure

The selection structure represents the logical structure for selecting one of two or more processing branches. The basic selection structure is to specify a condition P, and then decide whether to execute calculation A or B according to whether the condition is true, that is, select one of the two branches to execute, as shown in Figure 7-4 (a). Calculation A or calculation B in the selection structure can also include order Select and cycle structure. The program language usually also provides a simplified selection structure, that is, a branch structure without calculating B, as shown in Figure 7-4 (b), and a multi branch selection structure.
 Select Structure

 

3. Cycle structure

The loop structure describes the process of repeated calculation. It usually consists of three parts: initialization part, the part that needs repeated calculation (called loop body), and the condition part for repeated calculation. The initialization part is sometimes not explicitly expressed. There are mainly two types of loop structure: while type loop structure and do=while type loop structure.

The logic meaning of while type structure is to judge condition P first, if it is true, execute loop body A, and then judge condition P, otherwise the control flow will exit the loop structure, as shown in Figure 7-5 (a).
 Cyclic structure


The logical meaning of the do while structure is to execute the loop body A first, and then judge condition P. If it is true, continue to execute the loop body A, and then judge condition P. Otherwise, the control flow will exit the loop structure, as shown in Figure 7-5 (b). An example of the calculation process represented by sequence, selection and cyclic structure is shown in Figure 7-6.
 Example of calculation process represented by sequence, selection and cyclic structure
Wherein, the calculation process shown in Figure 7-6 (a) means that shilling x obtains a value of 5, then y obtains a value of 7, finally the values of x and y are added and the results are stored in two; The calculation process shown in Figure 7-6 (b) means that first judge whether the value of x is greater than y, if so, let max obtain the value of r, otherwise let ma x obtain the value of y; The calculation process shown in Figure 7-6 (c) shows that shilling i obtains a value of 0, then judges whether the value of i is less than 10, if so, increases the value of i by 1, then judges the value of i to determine whether to continue to increase, and repeats the process until the value of i is equal to 10.


Please contact our consultant

+86 10-60259772

Please provide your contact number. The project manager of shangpin China will contact you as soon as possible.