liangshaopeng

Results 3 comments of liangshaopeng

extern void insert_element(multiset& m, multiset& M, double x){ ``` if(m.empty() || x < *(m.begin())) M.insert(x); else m.insert(x); if(m.size() > M.size() + 1){ multiset::iterator i; i = m.begin(); m.erase(m.begin()); M.insert(*i); }...

any input will lead to this ,this is not about M is empty or not , this is c++ stl use fault . you can debug this function in gdb...

i = M.begin(); M.erase(M.begin()); m.insert(_i);-------------------->_i is a random double , because i is Invalid after M.erase(M.begin()); i switch like this , i = M.begin(); m.insert(*i); M.erase(M.begin());