Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /*SI = Simplu înlantuită
- *DI = Dublu înlantuită
- *DIS = Dublu înlantuită cu santinelă
- */
- typedef struct Nod {
- struct Nod *next, *ant;
- int x;
- } Nod_t, *List_t, **AList_t;
- void PrintList (List_t sant){
- List_t lista = sant->next;
- while(lista != sant){
- printf("%i ", lista->x);
- lista = lista->next;
- }
- }
- List_t PopulateList(char* fis){
- List_t lista, sant;
- int nr;
- FILE *f = fopen(fis, "rt");
- sant = (List_t)malloc(sizeof(List_t));
- sant->next = sant->ant = NULL;
- lista = sant;
- //First node
- while(!feof(f)){
- fscanf(f, "%i", &nr);
- lista->next = (List_t)malloc(sizeof(List_t));
- lista->next->x = nr;
- lista->next->ant = lista;
- lista = lista->next;
- }
- sant->ant = lista;
- lista->next = sant;
- return sant;
- }
- int main (){
- List_t lista1;
- lista1 = PopulateList("1.txt");
- PrintList(lista1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement