cin>>x; for(auto i=lst.begin();i!=lst.end();i++) { if((*i)==x) { i=lst.erase(i); } }
这样子为什么会导致list中值为x的元素删不干净
x
eg. 1 3 3 3 4
删除3
结果却是 1 3 4