struct Lista {
struct Nod * first;
struct Nod * last;
int size;
};
struct Lista * createList() {
struct Lista * list;
list = (struct Lista*)malloc(1*sizeof(struct Lista));
list -> first = NULL;
list -> last = NULL;
list -> size = 0;
return list;
}
newNod -> nume =(char*)malloc(strlen(nume_dat)*sizeof(char));
strcpy(newNod -> nume,nume_dat);
newNod -> test = persoana;
return newNod;
}
int listIsEmpty(struct Lista * list) {
if(list -> first == NULL && list -> last == NULL) {
return 1;
}else{
return 0;
}
}
struct Lista * insert(struct Lista * list,char *nume/struct elev persoana) {
struct Nod *nod1;
nod1 = createNod(nume/persoana);
if(listIsEmpty(list) == 1) {
list -> first = nod1;
list -> last = nod1;
}else{
if(listIsEmpty(list) == 0) {
/* nod1 -> next = list -> first; //inserare la inceput
nod1 -> prev = list -> first -> prev;
list -> first -> prev = nod1;
list -> first = nod1;
list -> size++;
return list;
}*/
nod1 -> prev = list -> last; //la sfarsit
nod1 -> next = list -> last -> next;
list -> last -> next = nod1;
list -> last = nod1;
list -> size++;
return list;}
struct Lista * deleteNod(struct Lista * list ,char * nume) {
struct Nod * curent;
curent = cautaNod( list, nume);
printf("numele gasit:%s\n",curent->nume);
if(curent == list -> first && curent == list -> last){
list -> first=NULL;
list -> last=NULL;
dezalocNod(curent);
return list;
}
if(curent -> prev == NULL){
printf("Este primul nod\n");
list -> first = curent -> next;
curent -> next -> prev = curent -> prev;
dezalocNod(curent);
list->size--;
return list;
}
if(curent -> next == NULL){
printf("E ultimul nod\n");
list -> last = curent ->prev;
curent -> prev -> next = curent -> next;
dezalocNod(curent);
list -> size--;
return list;
}
else{
curent -> prev -> next = curent -> next;
curent -> next -> prev = curent -> prev;
dezalocNod(curent);
list -> size--;
return list;
}
}
int main() {
struct Lista * list = createList();
struct Elev exemplu;
char nume[20],cnp[13];
int i,nota;