#include<iostream>
using namespace std;
#include<list>
void Solution(list<int>& l)
{
for (list<int>::iterator it = l.begin(); it != l.end(); it++)
{
bool judge = 0;
for (list<int>::iterator fit = l.begin(); fit != it; fit++)
{
judge = judge || (*fit==*it);
}
if (judge)
{
l.erase(it);
}
}
}
void PrintList(list<int> l)
{
for (list<int>::iterator it = l.begin(); it != l.end(); it++)
{
cout << *it << " ";
}
cout << endl;
}
void test01()
{
list<int> lis;
lis.push_back(1);
lis.push_back(2);
lis.push_back(3);
lis.push_back(3);
lis.push_back(2);
lis.push_back(1);
PrintList(lis);
cout << "-----------------------------------------" << endl;
Solution(lis);
PrintList(lis);
}
int main()
{
test01();
system("pause");
return 0;
}