Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Pumpkinizer

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

I just submitted 160A - Twins , in my compiler "codeblocks" it works perfectly and the initial tests are correct, it retruned wrong answer on test 1 when I submitted so I tested it in the custom test where I'm sure I put the exact same code, it returns wrong answer...

can anyone help me and explain what is the problem here ?

![ ](Hebergeur d'image)

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

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

your code is wrong in my compiler too...

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

You didn't initialize the variable sum.

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

    Well thank you for correcting, although my code is still a wrong solution . the problem is that I still don't understand why does my compiler gives a different result other than codeforces's compiler...

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

      If you didn't initialize the variable, it can have any value. E.g:

      int main() {
          int i;
          printf("%d\n", i);
      }
      

      That print might print anything, and it might even be different when you run the same executable twice. It's essentially your fault for writing code that uses the value of an uninitialized variable.

      By the way, code::blocks is not a compiler.