-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlinkedlist_fonksiyonel.cpp
More file actions
58 lines (52 loc) · 1.14 KB
/
linkedlist_fonksiyonel.cpp
File metadata and controls
58 lines (52 loc) · 1.14 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
56
57
58
/* NOTES:
listeler sequential(sıralı erişim), diziler ramdom
*/
#include "stdio.h"
#include "stdlib.h"
struct Node{
int data;
Node *next;
};
typedef Node node;
//fonksiyon prototipleri
void Display(node *toor);
void AddLast(node *toor, int value);
//main
int main(int argc, char const *argv[]) {
node *root;
root=(node *)malloc(sizeof(node)); //hafizada node boyutunda root için hüçre oluştur.
root->next=NULL;
root->data=16;
//listenin sonuna 3 eleman eklemek
for (int i = 1; i < 9; i++) {
AddLast(root,i);
}
//
node *iterator=root;
for (int i = 0; i < 3; i++) {
iterator=iterator->next;
}
//Araya eleman eklemek
node *temp=(node *)malloc(sizeof(node));
temp->next=iterator->next;
iterator->next=temp;
temp->data=444;
Display(root);
return 0;
}
//Display
void Display(node *toor){
while (toor != NULL) {
printf("-->%d", toor->data);
toor=toor->next;
}
}
//Listenin sonun eleman ekle
void AddLast(node *toor, int value) {
while (toor->next != NULL) {
toor=toor->next;
}
toor->next= (node *)malloc(sizeof(node));
toor->next->data= value;
toor->next->next=NULL;
}