Recently read Rujia write algorithm Primer classic feel their foundation is too rotten so summed up some of our more easy to make mistakes to everyone see (Daniel don't look at O (∩_∩) o)
1. Floating-point number: two integers calculate the floating-point number must be the integer first into a floating-point number 5-0.1 the computer first turns 5 to 5.0 before the calculation
2. XOR operation: This is a very mysterious thing. If you want to find a single number in an array, then you can use XOR or a two-digit interchange a = a^b; b = a ^ b; A = a ^ B; it transforms the implementation.
Own xor or self equals 0;
3. Logical operators are short-circuit operators a| | b If A is true then you don't count the back.
4 I'm sure some people don't know the scope of int is probably over 2 billion.
5. Output 1.0/0.0 and 0.0/0.0 will not be error and will not run, but 1/0 will collapse with \\n output \ n with%%d output%d
6.doublt save Six decimal places, Float:1bit (sign bit) 8bits (digit digit) 23bits (digits) double:1bit (sign bit) 11bits (digit) 52bits (digit digit)
7.! The priority is the highest | | Is the same as the priority of &&
8. Look at the cosine expression: cos (X/180*M_PI)
9.floor (x) to find an integer part of x but to write such a sub floor (x + 0.5) Fear of error
10. This is the wrong thing that I've been through all night. if (i = 1) you should see something wrong. There must be two equals sign "= ="
The factorial of 11.25 is followed by six 0
(double) S/n can directly output double type
13.printf ("Time used =%.2lf", (double) CLOCK ()/clocks_per_sec), the runtime of the output program needs to use the #include<time.h> header file
14. Copy k elements from array A to array B memcpy (b,a,sizeof (int) * k) int can be changed to double
15.assert (x >= 0) If X<0 then the program will end abnormally this thing is usually used to verify the function's return value needs to be used Assert.h
16.C language uses call stacks to describe call relationships between functions
17. The address of the first byte of each variable in memory is the address of the variable
. exe files have three parts of the body segment: Store instruction Data segments: Store initialized global variable BSS segments: Space required to store unassigned global variables
19. Segment overflow: Each recursive call will add a stack frame inside the stack, and over time will cross over. This is why the large array is outside of main because if the large array is a local variable, it will cause a segment overflow.
20. The address of the local variable is freed after the function executes.
21. Matrix problem Matrix The left slash above the y-x is the same right slash above the x+y is the same
That's all. Continuous update
Tips for getting Started with algorithms