代码拉取完成,页面将自动刷新
/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
using namespace std;
void show(auto container,string sep=" ")
{
for(auto ele:container)
{
cout << ele << " ";
}
cout << endl;
}
int main_16()
{
list<string> str_list({"Apple","Banana","Blueberry","Pear","Orange","Grapes","Strawberry"});
show(str_list);
cout << "delete the first element" << endl;
str_list.pop_front();
show(str_list);
cout << "delete the last element" << endl;
str_list.pop_back();
show(str_list);
string fruits[]= {"Pear","Watermelon"};
for(string fruit:fruits)
{
auto iter=find(str_list.begin(),str_list.end(),fruit);
if (iter!=str_list.end())
{
str_list.erase(iter);
cout << fruit<<" Exist" << endl;
cout << "delete "<<fruit << endl;
}
else
{
cout << fruit<< " doesn't exist" << endl;
}
show(str_list);
}
str_list.erase(++str_list.begin(),--str_list.end());
cout << "delete a range" << endl;
show(str_list);
str_list.clear();
cout << "clear" << endl;
show(str_list);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。