#include < stdio.h >
#include <stdlib.h >
#include < conio.h >
struct node
{
int value;
struct node *next;
};
typedef struct node node;
void initialization();//listeye ilk deðer verme islemleri
void add(int,node**);//eleman eklemek icin fonk
int main () {
initialization();
getch();
return 0;
}
void initialization(){
node *current ,*head;
head=NULL;
int added=1;
printf("Listenizin elemanlarini girin\nbitirmek icin 0 basin :\n");
while(added!=0){
scanf("%d",&added); //her seferinde elemanlar alýnýyor
add(added,&head);//her seferinde eklenmek üzere fonksiyona gönderiliyor
printf("\n");
}
printf("Bagli listenizin elemanlari sirasiyla :\n");
current=head;
while (current) { //NULL görene kadar devam
printf("%d\n",current->value);
current=current->next;
}
}
void add(int a,node** head){ //sýralý eklemek yapmak icin
node *previous=NULL,*added,*current;
added=(node*)malloc(sizeof(node));//ihtiyac oldukca belek ayýrýyor
added->value=a;//gelen deðeri value kýsmýna atýyor
added->next=NULL;// göstericisini sýfýrlýyor
current=*head;
while (current!=NULL && (added->value)>current->value){ //sýralý ekleme yapmak icin
previous=current;
current=current->next;
}
if(previous==NULL)
*head=added;
else{
previous->next=added;
}
added->next=current;
}