#include <iostream>
#include <list>
#include <iterator>
#include <algorithm>
#include <conio.h>
using namespace std;
int main()
{
list<int> intList1, intList2, intList3, intList4;
ostream_iterator<int> screen(cout," ");
intList1.push_back(23);
intList1.push_back(58);
intList1.push_back(58);
intList1.push_back(58);
intList1.push_back(36);
intList1.push_back(15);
intList1.push_back(93);
intList1.push_back(98);
intList1.push_back(58);
cout<<"Line 12: intList1: ";
copy(intList1.begin(),intList1.end(),screen);
cout<<endl;
intList2 = intList1;
cout<<"Line 16: intList2: ";
copy(intList2.begin(),intList2.end(),screen);
cout<<endl;
intList1.unique();
cout<<"Line 20: After removing the consecutive "
<<"duplicates,"<<endl
<<" intList1: ";
copy(intList1.begin(),intList1.end(),screen);
cout<<endl;
intList2.sort();
cout<<"Line 24: After sorting, intList2: "; //Line 24
copy(intList2.begin(),intList2.end(),screen);//Line 25
cout<<endl;
intList3.push_back(13);
intList3.push_back(23);
intList3.push_back(25);
intList3.push_back(136);
intList3.push_back(198);
cout<<"Line 32: intList3: ";
copy(intList3.begin(),intList3.end(),screen);
cout<<endl;
intList4.push_back(-2);
intList4.push_back(-7);
intList4.push_back(-8);
cout<<"Line 38: intList4: ";
copy(intList4.begin(),intList4.end(),screen);
cout<<endl;
intList3.splice(intList3.begin(),intList4);
cout<<"Line 42: After moving the elements of "
<<"intList4 into intList3,"<<endl
<<" intList3: ";
copy(intList3.begin(),intList3.end(),screen);
cout<<endl;
intList3.sort();
cout<<"Line 46: After sorting, intList3: ";
copy(intList3.begin(),intList3.end(),screen);
cout<<endl;
intList2.merge(intList3);
cout<<"Line 50: After merging intList2 and intList3, "
<<"intList2: "<<endl<<" ";
copy(intList2.begin(),intList2.end(),screen);
cout<<endl;
intList2.unique();
cout<<"Line 54: After removing the consecutive "
<<"duplicates, intList2: "<<endl
<<" ";
copy(intList2.begin(),intList2.end(),screen);
cout<<endl;
getch();
return 0;
}
Sabtu, 06 Oktober 2012
Link List
Langganan:
Posting Komentar (RSS)
Komentar :
Posting Komentar