In-system:
L Milling (Nian) Division: Decimal to a few binary, except a few, from the bottom to see the remainder (decimal to Binary, decimal to octal, decimal to hex)
L binary conversion to decimal: directly multiplied by the number of times of the square;
L binary : binary;octonary: octal;hexadecimal: hexadecimal;
Original code, anti-code, complement: "Data storage Form": (When the computer stored is the complement)
L -1: Original code:10000001
Anti-code:11111110
Complement:11111111
When a negative number is complementary, the sign bit does not participate in the operation
L Positive Number: The original code anti-code is the same;
L negative Number: Complement = The original code to take the inverse plus one, the sign bit does not participate in the Operation
L (when the negative number is only the highest bit is 1 o'clock, such as:1000 0000 The sign bit is also the data bit, when the negative number is more than the highest bit is 1, the other bit also has 1 o'clock, the sign bit is only the sign bit, does not participate in the Operation )
Short A=-17;
-17: Original code:10000000 00010001
Anti-code:11111111 11101110
Complement:11111111 11101111//0xffef;
The data stored in the computer is in the form of complement, when the output is converted to the original code to read the output.
{
Short a=-32768;
Short b=a+1;
printf ("%d", b);
Convert -32768 to complement form , the complement is calculated, and the result is converted to the original code output to B;
}
the difference between ' 0 ' and ' + ':
' + ': is an escape character, which is a null character, cannot be displayed, the corresponding value in ASCII is 0,
When defining a char type,' \ n ' is the same as 0, i.e.char a= '/'; char a=0;
When defined separately as:int i=0; char j= ' n '; the two are not the same, with 4 bytes in front and 1 bytes behind
Character ' 0 ': the corresponding numeric value in the ASCII code represented is ;
Program:
L GetChar (); The request terminal gets a character that is often used to let the console stay with the system ("pause");
L sizeof (a)//calculates the number of bytes that a occupies in memory;
How many bytes of int in memory do l integer? Correct answer:sizeof (int) bytes;
L How to view memory: Set a breakpoint, run a breakpoint, get an address. Click Debug -"Window -" Memory to view memory, and then set the breakpoint to the next line,F11-line run, see the data in memory changes.
L %: The remainder can only be a whole number, the residue can not be 0;a%b The sign of the result symbol to see A;
L/b ; divisor b cannot be 0;
Bits, Bytes, and words:
L-bit:bit;
L byte:byte; 1byte=8bit;
L Word: two bytes;
L Uint: It corresponds to a 32-bit unsigned integer (unsigned int)
L Static: Defines a static variable or function; Modified variable data does not free up space because the function exits
L size_t: is used to define unsigned integers; thesize_t in a 32-bit system is 4 bytes , whereas in 64-bit systems,size_t is 8 bytes, This type can be used to enhance the portability of the program, and the result of thesizeof () operator operation is the size_t type
The type of L float can only represent a maximum of 7 valid values, the default is 6 decimal places;
L floating-point number of allowable error expression:
ABS (x-y) <1e5;
Determine if two floating-point numbers are equal:
IF (ABS (x-y) <1e5)
Floating-point numbers follow the rounding principle when printing in%M.N format
Print format control:
l %hd (Short integer %d (integer %p (print address %u (unsigned integer %ho (print short type integer in octal format Span lang= "en-us"), %lo (printed in octal format long type integer %lu (print unsigned long-type integer %ld (print Span lang= "en-us" >long type integer );
%llu (print unsigned long long integer );%lld (prints a long long integer );
L %M.N (m: The total width of the character (including the decimal point)N: n digits after the decimal point, the intercept is rounded;)
L %g: Scientific counting method and floating-point representation intelligent selection of a method output;
L %p: Format control for printing addresses;printf ("%p", &a);
L %0: Auto -Fill 0, if the vacancy is low, do not fill 0, if the vacancy in the high, then 0; (only right alignment, and there is a vacancy only to fill 0; Left alignment does not need to fill, otherwise it changes the original value)
Escape characters:
L \v: Vertical vertical
L \ r: Move the current seat to the beginning of printf ("11111\r22"); result : 22111
Char type
The char type actually stores integers instead of characters, because each character corresponds to a corresponding integer in an ASCII code: a particularcharacter is represented by a specific integer, such as:A---> 65; ASCII code value range:0-127)
the L char type can perform subtraction operations.
The type has an implicit conversion condition :
1) when assigning values;
2) When a different data type participates in the operation (low byte to high byte conversion) (two type is the same byte number, long long to double (decimal precision is higher than the integer));
3) when transmitting the parameters;
4) when an assignment is done, the left side of the equals sign is converted to the right type of the equals sign (precision is missing);
Cast:int (x+y); (int) x; (int) (x); Casts are not automatically rounded
Priority level:
Operators of the same precedence, the order of operations is determined by the binding direction.
Simple Note is:! > Arithmetic operators > Relational operators > && > | | > Assignment Operators
If condition judgment:
(1) No matter how many if....else ... statements are counted as a single judgment statement
(2) Switch (i) choose to Judge the case can contain more than one statement;
(3) The value of an assignment expression is the value to the right of the equal sign;
Loop statement:
Break
Continue Skip this cycle
Return return function, end of function execution
Goto; use with label
Time seed :
void typing_speed ()
{
int i,j;
Srand (Time (NULL));
//Time seed , if a time seed is not pre-defined, when the program executes the typing_speed () function for the second time,rand () randomly comes out with the same data as the function that was previously called randomly; use srand (NULL)) After that, the random data is different.
char arr[100] = "DGSHDGAWSFJ e;wloitrfbdjmhfjcdxagfasgwyhetwhfrdskajgfoiueraiwehfkdsh";
for (i = 0; i < strlen (arr); i++)
{
J =500 + rand ()% 1000;
SetTimeout (j);
printf ("%c", Arr[i]);
}
}
Random number:
Rand ()% (n-m+1) +m
Its principle is, for any number, 0<=rand ()% (n-m+1) <=n-m so 0+m<=rand ()% (n-m+1) +m<=n-m+m namely M<=rand ()% (n-m+1) +m <=n
Self-increment/decrement:
{
int a=3,b=2;
A=++a---b; The result is a=3,b=1; ++a in this operation, the first implementation of the a+1 operation,a first equals 4, and then perform--b operations, and then the Operation a= ++a---b assignment Operation
a=a++-b--; The result is a=2,b=1; a++ in this operation, the first implementation of the operation of a, and then perform --b operation, and then a= a++---b assignment Operation , and then the value of a plus 1 operation
}
The minus sign (-) is the same as the precedence of the decrement operator, combining the data in a right-to-left combination, such as:
b =-a---b++-C + +-d++; Equivalent to B =-(a--)-b++-C + +-d++; right -to-left combination
5++ + + (a++) (x+y) + +//Several spelling errors a++ is an expression that cannot be self -increment (floating-point numbers can be self-decreasing )
Move left shift right:
L Move left several is by 2 several times, the right shift several is except 2 several sides;
L {int a=10;a<<2;printf (%d,a);} Result : 1010<<2à101000->40; (int four bytes; there are 32 bits, so there is no overflow on the left, there are many digits )
To calculate the length of an integer array:
sizeof (ARR)/sizeof (int);
Macro definition:
#define A (x) x*x
A=a (10); a=10*10=100;
B=a (5+5); b=5+5*5+5=35; Pure substitution, no parentheses
Basic knowledge of C language