arasmus's blog

By arasmus, history, 8 years ago, In English

19194587
The code gives runtime error .
the line mod1[X%10].push_back({X/10,f,s}) is causing the problem , if u comment it out everything runs fine
How can this simple push_back() cause a RE (array index of mod1 vector are in bound)

  for(int s=0;s<=6;s++)
for(int f = 0; (f+s)<=6;f++){
int X = s*7 + f*4;
mod1[X%10].push_back({X/10,f,s});
}
  • Vote: I like it
  • -15
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It should be string digit[7]; instead of 6.
You now get WA on test 2