-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUntitled2.cpp
65 lines (53 loc) · 1.17 KB
/
Untitled2.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
#include<stdio.h>
#include <stdlib.h>
struct node{
int element;
struct node *next ;
//node * next ;//^^eibhabei lekha jay
};
struct node * h = NULL ;
void insert (struct node *dummy ,int n){
struct node *temp =dummy;
while(temp->next!=NULL){
temp= temp->next;
}
struct node * new_node =(struct node *)malloc(sizeof(struct node));
new_node ->element = n;
new_node ->next =NULL;
temp ->next = new_node ;
//printf("%d\n",*new_node);
}
void traverse (struct node *dummy ){
struct node *i =dummy;
while(i->next !=NULL ){
i=i ->next ;
printf("\n%d",i->element);
}
//printf("%d",*dummy);
}
struct node * find (struct node * dummy ,int v){
struct node *i =dummy;
//printf("dfghj");
while(i->next !=NULL ){
i=i ->next ;
//printf("\n%d",i->element);
}
if (i->next ==NULL)printf ("\n FOUND!!");
/*while(i->next ==NULL ){
i=i ->next ;
/* if (i==NULL){
printf("\n%d not found",v);}*/
//printf("%d",v);
}
int main (){
struct node* list = (struct node*) malloc (sizeof(struct node));
list -> next = NULL;
insert (list,60);
insert (list,70);
insert (list,80);
insert (list,90);
insert (list,100);
traverse (list );
find (list ,75);
return 0;
}