Facebook
From Whipped Hog, 5 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 251
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct Lista_dwukierunkowa
  5. {
  6.     int dana;
  7.     struct Lista_dwukierunkowa *nast, *poprz;
  8. } Lista;
  9. Lista *utworz_element(int dana)
  10. {
  11.     Lista *tmp;
  12.     //dana = (int*)malloc(sizeof(int));
  13.     tmp = (Lista*)malloc(sizeof(Lista));
  14.     tmp->dana=dana;
  15.     tmp->nast=NULL;
  16.     //element->poprz=tmp;
  17.     return tmp;
  18. }
  19. void push_front(Lista *element, int dana)
  20. {
  21.     if(element);
  22.     Lista *tmp;
  23.     utworz_element(dana);
  24.     element->nast=NULL;
  25.     element->poprz=tmp;
  26. }
  27. void show(Lista *element)
  28. {
  29.     Lista *tmp;
  30.     tmp=element;
  31.     while(tmp)
  32.     {
  33.         printf("%d ", tmp->dana);
  34.         tmp=tmp->nast;
  35.     }
  36. }
  37. int main()
  38. {
  39.     printf("Hello world!\n");
  40.     Lista lista;
  41. //    lista=0;
  42.     push_front(&lista,2);
  43.     push_front(&lista,3);
  44.     show(&lista);
  45.     return 0;
  46. }
  47.