C语言教程 第一课(国外英文资料)
C语言教程 第一课(国外英文资料)
The thread of the solution Only one inlet and an outlet flow chart of each step has a chance to be executed According to the different internal structure considering different process structure can't appear "infinite loop" internal structure appeared "dead cycle"
Structured programming
Structure of sequential structure branching structures
Sequential structure
Example: take the sum of two examples:
1, enter a number a 2, type a number b 3, calculate a plus b, 4, the output (a + b)
The flow chart of the two Numbers
Start
The INPUT
Start-stop box: start-stop box: here is the beginning of the program input and output box: input/output box: here are used to process the box input two Numbers: processing box: here for two together input output box: input/output box: here is used for displaying and start-stop box: start-stop box: this is the end of the program
C = A + B
The DISPLAY C
The Stop
Sequential structures (classroom exercises)
Find the average of the three, there are two bottles A and B, respectively, vinegar and soy sauce, there are two bottles and, vinegar and soy sauce, serving to swap them
Branching structure
Example:
-- the largest of the two Numbers
Branching structure
algorithm
So, if you put in two Numbers, X, Y,.-2, when X, >, Y, when X is equal to Y, you output X output minus 3, otherwise the output, otherwise output Y
So let's start with X, Y input X, Y
is
X > Y X > Y?
no
The output output x x
Output Y output Y
End bundle
Branching structure
Enter a number, whether it is more than 1000, if input a number, whether it is greater than if it is more than 1000 output, otherwise, the output, the output 1, otherwise 0, the parity of the judge a number greater than the output output for the largest number of the three
Loop structure
5!
beginning
Define two variables, sum = 1, and define two variables, sum = 1, and I = 1, sum = 1
I < = 5? I < = 5? Whether Sum is equal to Sum * I output Sum
I + 1
Classroom practice
1 + 2 + 3...... The sum of plu