SlideServe
Menu
Préférences
© SlideServe · v2026

Mastering the OI Programming Process: From Problem Reading to Program Finalization

xanthe avatar
19 diapositives · 337 Views · Oct 15, 2014

This comprehensive guide outlines the essential steps in the OI programming process, covering reading and understanding problem statements, effective thinking techniques for problem-solving, coding, and debugging. It emphasizes the importance of analyzing problem constraints, the types of problems encountered, and the necessity of thorough testing. Additionally, practical coding tips, debugging strategies, and the significance of program finalization are provided. Follow these steps to enhance your programming skills and tackle problems efficiently, ensuring a clear pathway from concept to execution.

Mastering the OI Programming Process: From Problem Reading to Program Finalization - slide 1
01 / 19Mastering the OI Programming Process: From Problem Reading to Program Finalization
1 / 17

Télécharger la présentation

Mastering the OI Programming Process: From Problem Reading to Program Finalization
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Advanced Programming 15 Feb 2003

  2. The “OI” Programming Process • Reading the problem statement • Thinking • Coding + Compiling • Testing + Debugging • Finalizing the program

  3. Reading… • Read the problem statements carefully • Note the constraints • Meaningful Range of variables • Execution time limit • Do not “guess” the meaning of the problem statements.

  4. Thinking • What is the ‘type’ of the problem? • DP? Graph? Maths? Others? • Have you solved a similar problem before? • How do you solve the problem without computer? • Can the problem be further divided into some easier sub-problems?

  5. Thinking (cont.) • Drawing diagrams may be useful (especially for DP and Graph problems) • Is the problem too simple? • If yes, look for tricks ;-) • Is the algorithm correct? • Any special cases? • Have you coded it before? • What were the difficulties you faced?

  6. Thinking (cont.) • Is the algorithm feasible? • How to code it in PASCAL? • Is it easy to code? • What is the approximate execution time? • How to store the data? • Integer? LongInt? String? Array of char? • Array? Linked-List? • Are there enough memory to store the data?

  7. Thinking (cont.) • Are there any (simple) ways to improve • Program execution time? • Ease of coding?

  8. Coding • Pre-processing (e.g. find primes) • Input • Process • Part 1, 2, …, N • Output • Save and compile your code frequently

  9. Coding (cont.) • Avoid long and complex expressions x:=(2*(y2-y1)*(x1*x1+y1*y1-x3*x3-y3*y3)-2*(x1*x1+y1*y1-x2*x2-y2*y2)*(y3-y1)) /(4*(x2-x1)*(y3-y1)-4*(y2-y1)*(x3-x1)); y:=((x1*x1+y1*y1-x2*x2-y2*y2)*2*(x3-x1)-2*(x2-x1)*(x1*x1+y1*y1-x3*x3-y3*y3)) /(4*(x2-x1)*(y3-y1)-4*(y2-y1)*(x3-x1)); r:=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1)); a:=2*(x2-x1); b:=2*(y2-y1); c:=x1*x1+y1*y1-x2*x2-y2*y2; d:=2*(x3-x1); e:=2*(y3-y1); f:=x1*x1+y1*y1-x3*x3-y3*y3; x:=(b*f-c*e)/(a*e-b*d); y:=(c*d-a*f)/(a*e-b*d); r:=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));

  10. Coding (cont.) • Copy-and-paste • Make sure the “source” is correct • Update all variables • Double checking required

  11. Testing • When to test your program? • After completing the whole program? • After writing each statement? • After coding each part? • After making changes to a part?

  12. Testing (cont.) • Print all important variables to screen • Print messages • Use debugger, inspect program behavior by running step-by-step

  13. Testing (cont.) • Sample Output • “A problem has Sample Output for two reasons: • To make you understand what the correct output format is • To make you believe that your incorrect solution has solved the problem correctly ”

  14. Testing (cont.) • Hand-made Input • Boundary Case • “Large” Input • Execution Time • Overflow

  15. Debugging • Some short-cut keys • F4 – Goto Cursor • F7 – Trace into • F8 – Step Over • Ctrl-F7 – Add Watch • Ctrl-F2 – Program Reset • Ctrl-F8 – Add BreakPoint • Alt-F5 – Screen Output

  16. Finalizing • Check I/O filename • Check Output Format • Trailing spaces? • Correct source/executable name? • Is the executable updated?

  17. Demostration • HKOI2003 Junior Q3 – Goldbach’s Conjecture • Read the problem statements, and think about the algorithms now ;-)

  18. Reading… • Given an integer N, find two primes p1,p2 such that p1+p2=N • p1 ≤ p2 • Minimize (p2-p1) • Minimum N = 4 • Maximum N = 10,000,000 (wow!) • Can N be odd?

  19. Thinking… • Find two primes… • if M mod pi = 0, where pi is a prime, then M is not prime. • So….the first step is to find some small prime numbers (up to ) • Then, write a function that uses these prime numbers to check for larger primes • Use a for-loop to find two prime numbers such that their sum is N • Feasible? Easy to write?