C++ 리스트


개요

C++ list
C++ 리스트
#include <iostream>
#include <list>

using namespace std;

int main() {
	list<int> l = { 3, 1, 4, 8 };
	for (int n : l) {
	    std::cout << n << '\n';
	}
}
// 3
// 1
// 4
// 8
#include <iostream>
#include <list>

using namespace std;

int main() {
	list<int> l = { 3, 1, 4, 8 };
	l.push_front(5);
	l.push_back(6);
	for (int n : l) {
	    std::cout << n << '\n';
	}
}
// 5
// 3
// 1
// 4
// 8
// 6

같이 보기

참고