刚刚测试 set 时,写了以下代码:
set
for (int i = 1;i <= 10;i ++) s.insert(i); for (int x : s){ if (x & 1) s.erase(x); }
但是它 RE 了。
那么,如何在遍历 set 的过程中删除元素而不 RE?