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

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

When I declare vector v[10] , inside the main() function like this,


#include<bits/stdc++.h> int main() { vector<int> v[10]; }

the program halts & stops responding.

But When I declare it at global, like this,

#include<bits/stdc++.h>
vector<int> v[10];
int main()
{
    //something
} 

It works fine.

Why ?

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

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

It works on my pc, as well as on custom test which you can check here: https://codeforces.com/problemset/customtest

It probably depends on the compiler, so try updating them (I use C++17).

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

Is 10 a bigger number? If so it may be possible that there aren't enough space on stack.