-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
55 lines (54 loc) · 1.23 KB
/
Node.cpp
File metadata and controls
55 lines (54 loc) · 1.23 KB
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
class Node{
int a;
Node *next;
public:
Node *head;
Node(int data)
{
a=data;
next=NULL;
head=NULL;
}
int takeInput()
{
int dta=a,length=1;
Node* tail=NULL;
while (dta!=-1)
{
if(head==NULL)
{
Node *n=new Node(a);
head=n;
tail=n;
length++;
}
else
{
Node *n=new Node(dta);
tail->next=n;
tail=n;
length++;
}
cin>>dta;
}
return length;
}
int get_find(int index)
{
Node *temp=head;
if(temp!=NULL)
{
for(int i=1;(i<=index && temp!=NULL);i++)
{
if(i==index)
{
return temp->a;
}
temp=temp->next;
}
}
else
cout<<"\nNo LinkedList..";
return 0;
}
};