Facebook
From Emerald Crow, 6 Years ago, written in C.
This paste is a reply to Re: Untitled from Walloping Anoa - view diff
Embed
Download Paste or View Raw
Hits: 390
  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(Lista *element, int dana)
  10. {
  11.     Lista *tmp;
  12.     dana = malloc(sizeof(int));
  13.     tmp = malloc(sizeof(Lista));
  14.     tmp->dana=dana;
  15.     element->nast=NULL;
  16.     element->poprz=tmp;
  17. }
  18. void push_front(Lista *element, int dana)
  19. {
  20.     if(element);
  21.     Lista *tmp;
  22.     utworz_element(tmp, dana);
  23.     element->nast=NULL;
  24.     element->poprz=tmp;
  25. }
  26. void show(Lista *element)
  27. {
  28.     Lista *tmp;
  29.     tmp=element;
  30.     while(tmp)
  31.     {
  32.         printf("%d ", tmp->dana);
  33.         tmp=tmp->nast;
  34.     }
  35. }
  36. int main()
  37. {
  38.     printf("Hello world!\n");
  39.     Lista *lista;
  40.     lista=0;
  41.     push_front(&lista,2);
  42.     push_front(&lista,3);
  43.     show(&lista);
  44.     return 0;
  45. }
  46.