Блог пользователя farzad.shbfn

Автор farzad.shbfn, 9 лет назад, По-английски

Hello everyone,

I was wondering what are the best ways to debug a code? I'm training for world-finals, sometimes simple printing values takes a lot of time and even worse, I end up changing the code and the final output gets messed up so it gets even more time to take it back to how it was. I mostly code in C++, and use Eclipse IDE and Geany editor.

any suggestions?

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

gdb is cool :P

»
9 лет назад, # |
  Проголосовать: нравится +28 Проголосовать: не нравится

Computer time is extremely valuable in the ICPC, and you don't want to use it for debugging. If you can't find the mistake in less than 5 minutes of printing values, print the code on paper and start reading it line by line very attentively while someone uses the computer for something else.

  • »
    »
    9 лет назад, # ^ |
      Проголосовать: нравится -11 Проголосовать: не нравится

    You are absolutely right, that's how we used to code last year at regionals, but this year i changed my team, they're great problem solvers and also good coders, but they never coded with this kind of pressure and speed, so technically i ended up being the only coder in the team. and there is not enough time for them to train and increase their abilities in coding.

    considering these conditions, what do you suggest? 1. i debug the code myself? (for 5 mins in terminal) 2. print the code, and read it myself? (or give it to them for reading — which it takes more time, because i need to explain them the code (and sometimes it's inevitable because i CAN NOT find the bug and need for their vision) 3. or if it didn't worked out in less than 10-15 minutes, skip it.

    we are actually practicing virtual contests of past world-finals, we tired them all, but still, we are not efficient.

    I'd really appreciate it.