#include#include #include
using namespace std;int main(){ vector vec={ 0,1,1,2,3,5,8,21,55,89}; list li={ 0,1,1,2,3,5,8,21,55,89}; auto ve=vec.begin(); auto it=li.begin(); while(ve!=vec.end()) { if(*ve%2) ++ve; else ve=vec.erase(ve); } while(it!=li.end()) { if(*it%2) it=li.erase(it); else ++it; } for(auto v:vec) cout< <<" "; cout<
运行结果: