Current location - Education and Training Encyclopedia - Graduation thesis - C language course design score processing program
C language course design score processing program
Review the most important knowledge points of C language! Look at everything you need to learn. Make sure you pass!

In general, it must be clear:

There are three kinds of 1) program structures: sequence structure, loop structure (three loop structures) and selection structure (if and switch).

2) read the program from the main () entrance, and then read it from the top order (loop when you encounter a loop, and choose when you encounter a choice).

3) Computer data is stored in the computer in binary form. The location where the data is stored is his address.

4) bit represents 0 or 1. Byte refers to bytes, and one byte = eight bits.

5) Be sure to remember how binary is divided into decimals.

Concepts are often tested:

1. Compiler preprocessing is not a part of C language, so it is no longer run. A program compiled in C language is called a source program and stored in a text file with ASCII values.

2. There is only one main function in each C language program.

3. No more functions can be defined in the function.

4, the algorithm must have an output, and it can have no input.

5.break can be used for loop structures and switch statements.

6. The comma operator has the lowest level.

chapter one

1) legal user identifier check:

The law requires letters, numbers and underscores. There are other elements that are wrong.

The first one must be a letter or an underscore. The first number is wrong.

Keyword cannot be used as a user identification symbol. Main define scanf printf is not a keyword. What puzzles you is that If can be used as a user identifier. Because the first letter in If is capitalized, it is not a keyword.

2) Legal form of real data:

2.333e- 1 legal, the data is 2.333x 10- 1.

Test formula: there must be a number before e and an integer after e.

3) Legal form of character data:

1' means that the character occupies one byte, and "1"means that the string occupies two bytes (including the closing symbol).

The ASCII value of "0" is 48, the ASCII value of "a" is 97 and the ASCII value of "a" is 65.

4) Integer is generally two bytes, character is one byte, and double precision is generally four bytes:

Generally speaking, you will compile the system into 16 bit or 32 bit system during the exam. In this case, forget it and do the same problem. Mastering an integer is generally two bytes, a character is one byte, and double precision is generally four bytes.

5) Inspection of escape characters:

Int a = 0x6d in the program is to give a hexadecimal number to the variable A. Note that 0x must exist here.

Int a = 06d in the program is in octal form.

In the escape character,' \x6d' is legal, so you can't write 0, and x is lowercase.

14 1' is legal, and 0 cannot be written.

"108" is illegal because 8 cannot appear.

6) Priority of arithmetic operation symbols:

At the same level, some are from left to right, and some are from right to left.

7) Forced type conversion:

Must be (int)a, not int(a). Note that there must be parentheses on the type.

Pay attention to the difference between (int)(a+b) and (int) a+b. The former is transformation A+B, and the latter is transformation A plus B.

8) Expression check:

If it is an expression, there must be a numerical value.

Assignment expression: the expression value is the leftmost value, a = b = 5;; The expression is 5, and constants cannot be assigned.

Self-addition and self-subtraction expressions: suppose a=5, ++a (6) and a++ (5);

Operation mechanism: ++a is to add 1 to the value of the variable, then put the obtained value into the variable A, and then use this.

The value of a ++a expression is 6, and A++is to take the value of the expression as 5 first, and then add 1 to the value of A to make it 6.

And put it in the variable A. After ++a and a++, if A is used in the following program, it is 6 in the variable A. ..

Examination formula: before use+before use, after use+before addition.

Comma expression: lowest priority; The value of the expression. The value of the expression on the rightmost side of the comma.

The numerical value of the expression (2,3,4) is 4.

9) bit operation inspection:

There will be one or two questions.

General handling method: Almost all problems of bit operation should be handled according to this process (first change decimal to binary and then decimal).

Example 1: char a = 6, b;

b = a & lt& lt2; The calculation of this kind of problem is to first convert the decimal 6 of A into binary, and then do bit operation.

Example 2: It must be remembered that,

Example 3: When no data is discarded,

The value of 10)0 18 is illegal. There is no 8 in octal, and every 8 is 1.

Both sides of the 1 1)% symbol are required to be integers. If it is not an integer, it is wrong.

12) Three cases of rounding and losing decimals:

1、int a = 1.6;

2 、( int)a;

3、

chapter two

1) format check of printf function;

%d corresponds to an integer; Characters corresponding to %c; %f corresponds to single precision and so on. Width, left alignment, etc.

%ld corresponds to long int;; %lf corresponds to double.

2) Research on 2)scanf function format;

Note that the second part of this function is&; An address like A is not;

Scanf("%d%d%*d%d ",& i, & ampb & amp;; c); Skip the third data entered.

3) Check 3)putchar and getchar functions:

Char a = getchar () has no parameters. Enter a character from the keyboard into the variable a.

Putchar('y' y') outputs the character y to the screen.

4) How to exchange the values in two variables X and Y (need to remember)

Can't put x=y, y = x;; Use the intermediate variable t = x;; x = y; y=t .

5) How to realize the program of keeping three decimal places and rounding to the fourth place (need to remember)

This has the significance of popularization. Note that x = (int)x is the decimal part removed.

chapter three

It is important to note that in C language, non-zero means logical truth, and 0 means logical false.

1) relational expression:

The numeric value of the expression can only be 1(true) or false).

When the relational expression is true, 1 is obtained. For example, 9 >; 8 This is true, so the value of the expression is1;

2) Logical expression:

Can only be 1 (for true) or 0 (for false).

A) *** Yes&& amp||! Three kinds of logical operation symbols.

b)! & gt& amp& amp& gt|| Priority.

C) pay attention to the short circuit phenomenon. I prefer to get it in the exam.

D) means that x is greater than 0 and less than 10. 0<x< does not allow 10 (please remember). Is to calculate 0.

3)if statement

Else is combined with the nearest if without else.

4) Conditional expression:

The expression 1? Expression 2: Expression 3

Note that when it is not 0, it is the numerical value of Expression 2, and when it is 0, it is the numerical value of Expression 2.

Exam formula: true before and after holidays.

5) Switch statement:

A) Be sure to pay attention to the difference between broken and unbreakable. For the two examples in the book (page 34), if there is no line break, as long as one case matches, the rest will be executed. If there is an interrupt, it will jump out of the swiche statement directly.

B) the switch can only be used with break, not with continue.

chapter four

1) Three cyclic structures:

a)for(); while(); There are three kinds of do- while ().

B) There must be two semicolons in the b)for loop. Don't forget.

C) When writing a program, you must pay attention to the condition that the loop must end, otherwise it will become an infinite loop.

The last while () of the do-while () loop; Semicolon cannot be lost. (Pay attention to correcting errors on the computer)

2) The difference between interruption and continuation

Memory method:

Break: it means to interrupt, so when you see break, you exit the whole loop.

Continue: means to continue (continue the loop operation), but to end this loop means that the remaining statements in the loop body will not be executed, jump to the beginning of the loop, then judge the loop condition and start a new loop.

3) Nested loop

There is a cycle, there is a cycle in it. This is very complicated, and it needs patience to calculate step by step. It is generally remembered that two layers deal with two-dimensional arrays.

4) while((c=getchar())! ='\n') and while(c=getchar ()! ='\n ')

Look at a = 3 first! = 2 and (a=3)! The difference between =2:

(! The = sign is higher than the = sign, so count 3 first! = 2) The first value of a is1; The value of the second a is 3.

Note in the exam: the importance of brackets here.

chapter five

Function: a program block with certain functions;

Parameter of 1) function, return value (schematic diagram):

Master ()

{

int a = 5,b=6,c;

c = add(a,b);

printf("%d ",c);

}

invoking function

A and b are real arguments.

The whole function gets a value.

The return value of the Add function.

int add ( int x,int y)

{

int z;

z = x+y;

Return z;

}

Called function

X and y are formal parameters.

The value returned by this function is an integer.

Z is the calculation result of this add function and the return value returned by the function to the main program.

The program is executed from top to bottom in turn. When the function add is encountered, the values of a and b are passed to the calling function, and the program is temporarily interrupted, waiting for the return value. When the return value is obtained, it will be executed sequentially.

2) Be sure to pay attention to the transfer between parameters.

The difference between real parameters and formal parameters, and the address. (exam points)

If the value is passed, the change of formal parameters will not change the change of real parameters.

If the address is passed, the change of formal parameters may change the change of actual parameters.

3) Check the function statement:

Must have: function name, function return type and function parameter type.

You don't have to know the name of the parameter.

Chapter vi

The essence of pointer variables is to put addresses, and general variables are to put values.

The difference between *p and p in int *p;

*p can be used as a variable; The function of * is to fetch the value in the back address p.

P is used as the address.

*p++ and (*p)++: It is very important to correct the wrong questions.

*p++ indicates that the address will change.

(*p)++ is the value to be changed.

Three-person doctrine: (exam focus)

Array name: indicates the address of the first element. Array name cannot be added by itself, it is an address constant name. (I took the exam many times)

Function name: indicates the entry address of this function.

String constant name: indicates the address of the first character.

Chapter VII

The important concept of 1 one-dimensional array;

Discussion on array a[ 10].

1 and a represent the array name, which is the address of the first element, that is, the address of element A [10].

2.a is an address constant, so it is an error to assign a++ or a=a+2.

3.a is a one-dimensional array name, so it is a column pointer, which means that a+ 1 skips a column.

Discussion on a[3][3].

1 and a represent the array name, which is the address of the first element, that is, the address of element A [10].

2.a is an address constant, so it is an error to assign a++ or a=a+2.

3.a is a two-dimensional array name, so it is a line pointer, which means that a+ 1 is a line jump.

4.a[0], a[ 1] and a[2] are also address constants and cannot be assigned. They are all column pointers, a[0]+ 1, a[ 1]+ 1, A [2].

5. Note that A is different from a[0], a[ 1] and a[2], and their base types are also different. The former is a row of elements, and the latter three are a column of elements.

Two-dimensional array problem solving skills;

If there is a [3] [3] = {1, 2, 3, 4, 5, 6, 7, 8, 9}.

Step 1: Write them as the first column, the second column and the third column.

A[0]à 1 2 3-> first line

A [1] 4 56-> prepared things

A [2] 7 8 9-> the third line

Step 2: This is very simple:

*(a[0]+ 1) We know that the first element in the first row jumps back to a column, so this is an a[0][ 1] element, so it is 1.

*(a[ 1]+2) We know that the first element in the second row jumps back to two columns. So this is the element a[ 1][2], so it is 6.

Be sure to remember: as long as it is a two-dimensional array topic, it must be written in the above format, and then it will be easier to do the problem.

Array initialization, one-dimensional and two-dimensional, one-dimensional can not be written, two-dimensional second must be written.

Int a [] = {1, 2} is legal. Int a [] [4] = {2,3,4} legal。 But int a [4] [] = {2 2,3,4} is illegal.

Row pointers in two-dimensional arrays

int a[ 1][2];

Where a is now a row pointer and a+ 1 skips a row of array elements. Pointer with (*)p[2]

A[0], a[ 1] is now a column pointer. A[0]+ 1 jumps to an array element. Used with *p[2] pointer array.

Remember the law of undressing:

A[2] becomes *(a+2) a[2][3] becomes *(a+2)[3] and then becomes *(a+2)+3).

This idea is very important.