Hello, everyone! As the exam approaches, today I am sharing some valuable insights—key concepts and common mistakes for Level 1. Due to limited time, this is a compilation by the author after reviewing all Level 1 past exam questions, currently focusing on C++. I hope that this sharing can help you suddenly understand a common mistake, which would be useful! If you have any questions during your preparation, feel free to comment. If you are in a hurry, you can also add my personal WeChat (ldw_0711) to inquire.
1. Computer Basics and Programming Environment
1. Input Devices: Mouse, Keyboard, Sensors
Input devices are the means by which we convey information to the computer.
Output Devices: Speakers, Monitors
Output devices are the means by which we receive information from the computer.
2. The basic unit in a computer is the byte (Byte): B
3. The CPU is used for computation.
4. Computer hardware mainly includes the arithmetic unit, control unit, memory, input devices, and output devices.
5. Storage—Content
6. Common debugging methods: Reading source code, outputting intermediate results, step-by-step debugging.
2. History of Computers/GESP History
1. Turing Test
2. Von Neumann Computer Architecture
3. Pure Blood Harmony/Harmony System—Operating System
4. The earliest materials used in computers were vacuum tubes.
5. A certain celebrity won an award; investigate the achievements of this celebrity in what direction:
According to conventional thinking, we choose the closest direction to what we are being tested on (e.g., artificial intelligence).
6. “Wang Xuan Award”—Mr. Wang Xuan—Chinese Character Laser Typesetting System
7. GESP will test Scratch, Python, and C++ languages; the knowledge points tested are similar at the same level.
3. Definition and Use of Variables
1. Declare the variable type first; you must initialize the variable before using it!!! (Almost every exam paper will have a question on this)
2. Naming rules for variable names (identifiers): (Almost every exam paper will have a question on this)
(1) Cannot start with a number.
(2) Cannot use C++ keywords (words that have already been defined with functionality).
(3) Cannot use symbols other than underscores.
(4) Variable names are case-sensitive.
3. Commonly tested non-keywords include (all of these have been tested):
cin cout scanf printf endl do
4. Basic Data Types (Integer, Floating Point, Character, Boolean)
Constant Data Type Format Specifier Byte Size
‘3’ char %c 1
true bool 1
3 int %d 4
3.14 float %f 4
3.1 double %lf 8
“3” string %s 16/32
1. Integer divided by integer results in an integer.
2. The most commonly used format specifiers are for floating-point types (float, double):
To retain n decimal places: %.nf %.nlf
3. Defining a char type variable takes 1 byte; defining an int type array takes (number of array elements * 4) bytes.
4. For constant decimals, the default type is double.
5. The ASCII value of ‘A’ is 65, ‘a’ is 97, and the difference between uppercase and lowercase letters in ASCII is 32.
6. Calculation results always lean towards higher precision through automatic conversion.
7. Strings cannot be operated on with numbers!
5. Control Statement Structures (Sequential, Loop, Branch)
1. Any while loop can be converted to a for loop, and vice versa (the reason is the logical equivalence mapping of the three elements of the loop).
2. Both for and while loops can lead to infinite loops.
3. The do … while statement’s loop body will execute at least once; keep this in mind.
4. Generally, continue is used under conditional judgment; break is used in loops and case…break.
6. Basic Operations (Arithmetic, Relational, Logical)
1. Assignment (=) assigns the value on the right to the variable on the left.
2. Equality check (==) compares whether the two sides of the equal sign are equal.
3. Operations are performed according to operator precedence; expressions in parentheses are evaluated first.
4. Integer divided by integer (without type conversion) results in an integer (this is tested very often!).
5. Integers cannot be modulo with floating-point numbers!
6. Digit extraction: Continuously take the remainder of the number by 10, then integer divide by 10, until the number becomes 0.
7. Integers starting with 0 are octal; integers without a prefix are decimal.
8. Ternary operator: condition ? result1 : result2
9. %% is used for escaping, meaning to print a %.
10. %2d occupies 2 characters in output.
7. Input and Output Statements
1. cin ends input when encountering operators, spaces, newlines, etc. For example:
cin >> a, if the input is 5+2, the value of variable a will be 5.
2. cout outputs the last value. For example:
cout << (3,2); the result will output 2.
3. Quotes need to match in pairs.
8. Others
1. Analysis method: Organize the code format and clarify the meaning of the code.
2. Special value method: Choose special values, substitute them into the code, and compare with the target result.
In conclusion
If you are interested or are also learning programming, feel free to add Lazy King’s personal WeChat (ldw_0711). I hope to provide some help on your programming journey!