侧边栏壁纸
博主头像
王小木博主等级

这是很长,很好的一生

  • 累计撰写 124 篇文章
  • 累计创建 39 个标签
  • 累计收到 3 条评论

目 录CONTENT

文章目录

c++ list的初始化与遍历

王小木
2021-05-22 / 0 评论 / 0 点赞 / 335 阅读 / 674 字
#include<stdio.h>
#include<iostream>
#include<list>
#include<string>
#include<algorithm>
using namespace std;


int main()
{
list<string> test;
list<int> score;
list<string>::iterator testiterator;
list<int>::iterator testscore;
test.push_back("no");
test.push_back("march");
test.push_front("ok");
test.push_front("loleina");
test.push_front("begin");
test.push_back("end");




score.push_back(100);
score.push_back(90);
score.push_back(80);
score.push_back(70);
score.push_back(100);
score.push_back(20);


testiterator=test.begin();
testscore=score.begin();
while(testiterator!=test.end())


{
cout<<*testiterator<<'\n';
testiterator++;
}
while(testscore!=score.end())


{
cout<<*testscore<<'\n';
testscore++;
}
return 0;
}
0

评论区