Strange error in C++

Revision en1, by fugazi, 2019-05-09 22:16:52

I am getting a very strange bug in my code for today's round problems B1, 2.

At a moment, I'm having a set of pairs.

[s]: {(1, 1), (1, 4), (1, 5), (1, 9), (1, 10), (2, 2), (2, 7)}

Then I'm accessing the last and second last element.

it = s.rbegin();  // prints *it = (2, 7)
it--; 
// prints *it = (1, 10)

But for some weird reason it jumps off (2, 2) and I'm unable to figure out why.

Any help will be appreciated.

Tags #c++, c++ error, strange, #help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English fugazi 2019-05-09 22:20:47 22 Tiny change: ' element. \n\n```\ni' -> ' element. (line 51-54 in mycode)\n\n```\ni'
en1 English fugazi 2019-05-09 22:16:52 498 Initial revision (published)