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

Автор last_hour, история, 6 дней назад, По-английски

Heyo Codefoworcers! As I was practicing some of the problems, I came across the problem 1553C - Penalty and while solving this I literally blown up CF OJ and my Laptop!!!

The fact is my submission 280945613 gets AC while getting {warning: control reaches end of non-void function [-Wreturn-type]} this on my laptop and also this is not the end!

**The code breaks the range i from 0 to <n = 10 and proceeds to i=10 ...you can check it out I ran this code on ideone.com it just works perfectly fine there as well, I literally don't have any idea about this. Even I changed compiler it still gets an AC. Drop your thoughts on it!

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

»
6 дней назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Are you sure that it is actually possible to reach the end of the loop? Probably you just can't do that and return always works before reaching the end.

Or maybe it just returns some value and it luckily doesn't affect the answer

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

    it returns I made a mistake

    but what it does is break the for loop condition still doesn't affect anything like it reaches iteration i =10

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

      Well, then it's UB and you are very lucky Maybe compiler is somehow thinking that if loop is ended it should return n+1 xd

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

        at the end of for loop, even if i write return i+1 it still remains the same

        why is that so

        I changed compiler still getting AC :')

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

Auto comment: topic has been updated by last_hour (previous revision, new revision, compare).