pta_【CPP0040】list应用测试

#include<iostream>
#include<list>
#include<algorithm>
using namespace std;
int main(){
int i,a[10],b;
for(i=0; i<10; i++){
scanf("%d",&a[i]);
}
scanf("%d",&b);//插入的数
{

list<int>L;
for (i = 0; i < 10; i++)
L.push_back(a[i]);
L.push_front(b);
list<int>::iterator it = L.begin();
for (; it != L.end(); it++)
cout << "[" << *it << "]";
cout << endl;
L.sort();
L.reverse();
L.pop_back();
for (it = L.begin(); it != L.end(); it++)
cout << "[" << *it << "]";
L.clear();

}
return 0;
}

 

 

posted @   a_true  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示