////////////////////////////////////////
// 2018/04/25 21:39:52
// list-front
// return the first element
#include <iostream>
#include <list>
using namespace std;
template<class T>
void print(list<T> l){
list<T>::iterator it = l.begin();
while (it != l.end()){
cout << *(it++) << " ";
}
cout << endl;
}
int main(){
int ary[] = { 1, 2, 3, 4, 5 };
list<int> li;
for (int i = 0; i < 5; i++){
li.push_front(ary[i]);
cout << "front:" << li.front() << endl;
print<int>(li);
}
return 0;
}
/*
OUTPUT:
front:1
1
front:2
2 1
front:3
3 2 1
front:4
4 3 2 1
front:5
5 4 3 2 1
*/