Skip to content

Instantly share code, notes, and snippets.

@Lazar955
Created May 27, 2015 12:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lazar955/bb4c350939f9639f3218 to your computer and use it in GitHub Desktop.
Save Lazar955/bb4c350939f9639f3218 to your computer and use it in GitHub Desktop.
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