-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.cpp
42 lines (40 loc) · 882 Bytes
/
list.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<iostream>
#include<list>
using namespace std;
void display(list<int> &l)
{
list<int> :: iterator it;
for(it=l.begin();it!=l.end();it++)
{
cout<<*(it)<<endl;
}
cout<<endl;
}
int main(){
list<int>list1;
list<int>list2;
int a,c,b=0;
cout<<"Enter two values,first enter 0(to enter value) and -1(to discontinue insertion) and second value enter the data to be inserted:"<<endl;
while(b!=-1)
{
cout<<"Enter the first value:"<<endl;
cin>>b;
if(b==(-1))
{
break;
}
cout<<"Enter second values:"<<endl;
cin>>a>>c;
list1.push_back(a);
list2.push_back(c);
}
display(list1);
display(list2);
list1.pop_back();
list1.pop_front();
list1.remove(1);
display(list1);
list1.merge(list2);
display(list1);
return 0;
}