Bo2SS

Bo2SS

2 Start Your Programming Journey with Vim

Writing Programs with Vim#

  • Save and exit: , ZZ
  • In Linux, everything is a file
    • The executable program a.out is essentially a file, a binary file
  • You can write C code in .cpp files, but not the other way around (writing C++ code in .c files)
    • Note: Some macros under the C11 standard are not compatible with C++

C Language Programming Standards#

How to Debug Programs#

  • Common knowledge: The program defaults to main() as the entry point
  • Function encapsulation: After defining a function, has it been called?
  • When compilation errors occur: Look for errors from top to bottom, debug
  • If it does not meet expectations: Try using printf to output variable values

Using Pirate OJ and Improving Programming Skills#

HZOJ-69: School Opening Exam 2: Date Judgment#

  • Image

Sample Input

1991 1 30
1991 1 32

Sample Output

Yes
No
  • Idea
    • Check for illegal input and whether the number of days in the month is reasonable (leap year)
    • Two versions
      • Complex if-else judgment: wildly nested
      • Space for time: create an array of days in the month
  • Code

Thoughts on Prime Number Problems#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.