Created
May 27, 2015 12:06
-
-
Save Lazar955/bb4c350939f9639f3218 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
int ubaciUSortiranuListu(LISTA lista, int noviPodatak){ | |
POKAZIVAC noviElement = malloc(sizeof(ELEMENT)); | |
POKAZIVAC tekuci = lista->glava; | |
POKAZIVAC prethodni = NULL; | |
if (tekuci==NULL) | |
{ | |
lista->glava = noviElement; | |
lista->rep = noviElement; | |
} | |
while (tekuci!=NULL && tekuci->podatak < noviPodatak) | |
{ | |
prethodni = tekuci; | |
tekuci = tekuci->sledeci; | |
} | |
if (tekuci==lista->glava) | |
{ | |
ubaciEleNaPocetakListe(lista, noviPodatak); | |
} | |
else | |
{ | |
if (tekuci==lista->rep) | |
{ | |
ubaciEleNaKrajListe(lista, noviPodatak); | |
} | |
else | |
{ | |
noviElement->podatak = noviPodatak; | |
noviElement->sledeci = tekuci; | |
prethodni->sledeci = noviElement; | |
} | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment