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

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

In this submisson: 2431151 In that line: "if(hour[i]==hour[i-1]&&min[i]==min[i-1]){"

In the beginning, i=0 so that hour[i-1] means hour[-1].Can someone please explain how can this pass the pretests?

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

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

what can i do?

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

Well I try run this code

#include <iostream>
using namespace std;
int main() {
    int arr[100];
    cout << arr[-1] << endl;
    return 0;
}

on Costum Test in codeforces. It return 0 and did not give runtime error. I don't know what they use when compiling, but maybe this can explain why that code pass the pretest

UPDT I mean it produce output 0 and did not give runtime error

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

In C++, a[i] means *(a+i). This code accesses the memory cell located 4 bytes before than hour[0].