gpt4 book ai didi

c++ - 使用迭代器遍历列表?

转载 作者:IT老高 更新时间:2023-10-28 12:46:44 26 4
gpt4 key购买 nike

我需要使用 C++ 遍历列表的示例。

最佳答案

您的问题的示例如下

  #include <iostream>
#include <list>
using namespace std;

typedef list<int> IntegerList;
int main()
{
IntegerList intList;
for (int i = 1; i <= 10; ++i)
intList.push_back(i * 2);
for (IntegerList::const_iterator ci = intList.begin(); ci != intList.end(); ++ci)
cout << *ci << " ";
return 0;
}

关于c++ - 使用迭代器遍历列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5470331/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com