-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinked list.cpp
59 lines (45 loc) · 1 KB
/
linked 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<iostream>
#include<stdlib.h>
/*
using namespace std;
struct node {
int data;
struct node *link;
};
struct node* at_end(struct node *ptr,int data){
struct node *temp =NULL;
temp= (struct node *) malloc(sizeof(struct node));
temp->data = data;
temp->link = NULL;
ptr->link= temp;
return temp;
};
struct node* at_beg(struct node* &head,int data){
struct node *temp =NULL;
temp= (struct node *) malloc(sizeof(struct node));
temp->data = data;
temp->link = NULL;
temp->link = head;
head = temp;
return head;
};
*/
/*int main(){
struct node *head =NULL;
head= (struct node *) malloc(sizeof(struct node));
head->data = 45;
head->link = NULL;
struct node *ptr= head;
ptr = at_end(ptr,2);
ptr = at_end(ptr,3);
ptr = at_end(ptr,4);
head = at_beg(head,5);
ptr = head;
while(ptr!=NULL)
{
cout<<ptr->data<<endl;
ptr=ptr->link;
}
return 0;
}
*/