forked from skywalker290/hack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode3.cpp
53 lines (48 loc) · 755 Bytes
/
code3.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
43
44
45
46
47
48
49
50
51
#include <iostream>
using namespace std;
class node{
public:
int data;
node *next;
node *prev;
node(int x){
data=x;
prev=NULL;
next=NULL;
}
};
class dll{
public:
node *head;
node *tail;
dll(){
tail=head=NULL;
}
void insert(int n){
node *temp= new node(n);
if(head==NULL){
head=tail=temp;
}
else{
tail->next=temp;
temp->prev=tail;
tail=temp;
temp->next=NULL;
}
}
void display(){
node *p=head;
while(p){
cout<<p->data;
p=p->next;
}
}
};
int main(){
dll obj;
obj.insert(1);
obj.insert(2);
obj.insert(3);
obj.display();
return 0;
}