Some Tips for C/C++ Programming

(Some of these entries only consider usability and do not take optimization into account; use with caution in production environments.)
1. C++ Universal Header (*Only usable with the GCC compiler)
#include<bits>
**Recommended only for competitive programming; otherwise, it may lead to unpredictable issues.
2. Improve yourself by practicing on Luogu’s theme library; for exams, use Luogu’s beginner and interview resources. If you’re too lazy to prepare, just feed it to AI.
3. When encountering algorithms/structures/data structures you don’t know, check oi-wiki: oi-wiki.org
4. Declare custom functions before the main function for convenience and reliability.
5. Sometimes, using string is more suitable than int for storing data (in special cases).
6. Use sort without hesitation; it’s much better than writing your own messy implementation (only available in C++).
7. Allocate larger arrays; as long as the problem doesn’t crash due to memory limits, just make the arrays larger.
8. Make good use of debugging features; when the program is unclear, set breakpoints and debug piece by piece.
9. It is recommended to use the VSCode compiler, as its Copilot can reduce debugging pressure.
10. For high-precision problems, you can use __int128 to gain points; loose data may pass directly (requires manual input/output; search for tutorials on Baidu).

Leave a Comment