#include<iostream>
#include<list>
using namespace std;
int main()
{
int ia[]={0,1,1,2,3,5,8,13,21,55,89};
list<int>ilist(ia,ia+11);
list<int>::iterator iter;
int k=0;
for(iter=ilist.begin();iter!=ilist.end()&&k<11;iter++,k++)
{
if(k%2!=0)
ilist.erase(iter);
}
cout<<"{";
for(iter=ilist.begin();iter!=ilist.end();iter++)
{
cout<<*iter;
cout<<",";
}
cout<<"}\n";
return 0;
}
[此贴子已经被作者于2007-10-17 17:22:13编辑过]