The 0,1 law in logical operation
0 && A ===> 0
1 && a ==> a
0 | | A = a
1 | | A ===> 1
By the above know any number with 1 phase or both is 1
Any number with 0 and both is 0.
Short-circuit operations occur only in logical expressions;
In or operations, when the first expression is true (not 0), or the second expression of the operation does not operate, the whole is the value of the first expression
At the time of the operation, when the first expression value is False, then the second expression of the operation is not evaluated, and the whole is the value of the first expression.
The computer treats the expressions on either side of the logical operator as conditional expressions;
C Language for the bar table in the process of the lag self-increment operation is: first with no self-increment before the conditions of judgment, and then immediately self-increment;
int i = 0;
int j = 2;
int k;
K = i++ && ++j;
The resulting i,j,k values are 1,2,0, respectively.
When is the problem true?
For C compiler software, the implementation of the "discipline, lenient towards others" guidelines, that is, the input time is not 0 true, the output of the time 1 bit true
About output and input functions:
The input and output is implemented by invoking the C system function.
Input: scanf () output: printf ()
The format character is the input and output function, let c decide the value output/in format message
printf ("%u\n",-1);-1 's complement of 32 1, which is output as unsigned integer decimal, then size is 2^32-1
printf ("%4d,%-2d,%06d", N, N, N);
The above%4d expression output with 4 bit output, if the number of digits more than 4, then retain the original number of digits, if not enough in left fill space
%-2d ........ ................. Right fill space
%06d ... .... ... .... ... .... .... ... .... ..... .... ..... .... ........................... Left fill 0 instead of space
printf ("%5.2f\n", 5.6);//5.2f represents the total number of digits 5 bits, of which the decimal place 2 bits, the integer bit 2 bits, the decimal point 1 bits
One basic principle: no loss of correctness in order to satisfy the output format
The format allows the precise, precise location to be located accurately and accurately so that it is positioned correctly;
2. Input function
scanf ();
int n;
scanf ("%d", &n);
The contents of "" in the scanf () function will never be printed to the screen; in fact, it is the format required for the user to enter data again.
We don't want to add anything other than format characters when we're programming.
Short-circuit operations and format characters