-
Notifications
You must be signed in to change notification settings - Fork 1
/
find dulicate.cpp
87 lines (77 loc) · 974 Bytes
/
find dulicate.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
ousing namespace std;
#include<iostream>
struct node
{
int data;
struct node *prev;
struct node *next;
};
struct node* start=NULL;
struct node* createnode()
{
struct node *temp;
temp =new (struct node);
cin>>temp->data;
temp->prev=NULL;
temp->next=NULL;
return temp;
}
struct node* insertnode()
{
struct node *p,*temp;
temp=createnode();
p=start;
if(start==NULL)
{
start=temp;
temp->prev=NULL;
temp->next=NULL;
}
else
{
while(p->next!=NULL)
{
p=p->next;
}
temp->prev=p;
p->next=temp;
temp->next=NULL;
}
}
void duplicate()
{
struct node *ptr;
ptr =start;
int arr[100]={0};
while(ptr!=NULL)
{
arr[ptr->data]++;
ptr=ptr->next;
}
for(int i=0;i<100;i++)
{
if(arr[i]>1)
{
cout<<i<<endl;
}
}
}
void traverse()
{
struct node *t;
t=start;
while(t->next!=NULL)
{
cout<<t->data<<endl;
t= t->next;
}
cout<<t->data;
}
int main()
{
for(int i=0;i<5;i++)
{
insertnode();
}
duplicate();
}