Programming thinking and Practice 程序设计思维与实践

Course Information and Announcements

Lecture slides

  1. Intro

  2. Chap1-3

  3. Chap4

  4. Chap5

  5. Chap7

  6. Chap8

Practice Problems

All the problems below are from Peking Online Judge (POJ). Submissions should be made directly to the automated judging system. Problems are classified into 10 different categories, and the lectures will cover essential algorithms and theoretical background for each particular category. The numbers in parentheses represent the difficulty of the problems (0: easiest, 10: hardest). The difficulty rating is subjective; you might find a 5-rated problem easier than a 4-rated one. But do not attempt the challenge problems unless you are sure that you can solve all the easier ones.

Common coding mistakes

for(i = 0; i < n; i++);
  some code

for(i = 0; i < 1000; i++)
  for(i = 0; i < 10; i++)
    some code

#define min(a, b) a<b?a:b // incorrect
#define min(a, b) (((a)<(b))?(a):(b)) // correct

If you get stuck…