- comments
- inline comments should be two spaces after the line of code
- if a single comment takes over two lines, use a multiline comment
- sols should have nearly the same structure, same names, etc. to avoid confusion
- avoid global variables
- for the brace languages, always use braces & space em out like:
for (int i = 0; i < 2; i++) {- an if-else should be like this:
if (x == 1) { System.out.println("x is 1"); } else { System.out.println("x isn't ig"); }
- an if-else should be like this:
- other stuff in the usaco guide (spaces between ops, tabs, etc.)
- use actually good variable names
- unless you need the preincrement value, use
i++over++ifor consistency
- naming
- variables and functions in snake_case
- class & struct names in PascalCase
- preferably, use
ifstream&ofstreamoverfreopen - NO MACROS
- naming
- variables & functions in camelCase
- class & struct names in PascalCase, same as c++
- for usaco problems, class name should be same as the input file name (irrelevant for ones that use stdin)
- use
KattioorBufferedReader
- naming same as c++
- when printing only a single line, use
printwith thefileargument - use
withinstead of settingsys.stdinandsys.stdout
cursed