Created
October 19, 2018 09:39
-
-
Save oguzhanvarsak/cda4e194b08a76e3dae4a820e4f2226e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
struct node { | |
int data; | |
struct node *next; | |
struct node *prev; | |
}*head=NULL; | |
struct node *yeniNodeOlustur(int gelen){ | |
struct node *yeniNode = (struct node*)malloc(sizeof(struct node)); | |
yeniNode->data = gelen; | |
yeniNode->next = NULL; | |
yeniNode->prev = NULL; | |
return yeniNode; | |
} | |
void ekle (int gelen); | |
void bastanSonaYazdir (); | |
void sondanBasaYazdir (); | |
int main() { | |
ekle(434); | |
ekle(6); | |
ekle(94); | |
ekle(414); | |
bastanSonaYazdir(); | |
sondanBasaYazdir(); | |
} | |
void ekle (int gelen) { | |
struct node *temp = head; | |
struct node *yeniNode = yeniNodeOlustur(gelen); | |
if (head == NULL) { | |
head = yeniNode; | |
return; | |
} | |
while (temp->next != NULL) { | |
temp = temp->next; | |
} | |
temp->next = yeniNode; | |
yeniNode->prev = temp; | |
} | |
void bastanSonaYazdir () { | |
struct node *temp = head; | |
printf("Bagli Liste (Duz): "); | |
while (temp!= NULL) { | |
printf("%d ",temp->data); | |
temp = temp->next; | |
} | |
printf("\n\n"); | |
} | |
void sondanBasaYazdir () { | |
struct node* temp = head; | |
if(temp == NULL) { | |
return; | |
} | |
while(temp->next != NULL) { | |
temp = temp->next; | |
} | |
printf("Bagli Liste (Tersten): "); | |
while(temp != NULL) { | |
printf("%d ",temp->data); | |
temp = temp->prev; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment