Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Dontony's blog

By Dontony, history, 5 years ago, In English

Can we create an array of size 1e6+1 in C++(in my IDE the code crashes),by any methods,or, using vectors would be better? Please comment on this!Thanks.

  • Vote: I like it
  • -12
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it +3 Vote: I do not like it

I think you should cast it as an integer like (int)(1e6+1). Probably post code for better help :)

»
5 years ago, # |
Rev. 2   Vote: I like it +4 Vote: I do not like it

Declare the array in the global. It's because when you declare variables inside a function, its limited to the stack size. And I think your IDE set the stack size smaller.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It worked by declaring the array as global.Thanks!