Advertisement
selkieautopsy13

Untitled

May 20th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int rozmiar=NULL;
  5.  
  6.  
  7. void push(int *dane,int liczba)
  8. {
  9.     rozmiar=rozmiar+1;
  10.     realloc(dane,rozmiar*sizeof(int));
  11.     dane[rozmiar-1]=liczba;
  12.  
  13. }
  14.  
  15. void wyswietl(int *liczba)
  16. {
  17.  
  18.     int *wsk=&liczba[0];
  19.     int i;
  20.    for(i=0;i<rozmiar;i++)
  21.    {
  22.        printf("%d \n",*(wsk++));
  23.  
  24.    }
  25. }
  26. int main()
  27. {
  28.     int  *dane;
  29.     dane = malloc(rozmiar*sizeof(int));
  30.  
  31.     push(dane,5);
  32.      printf("Liczby w stosie: \n");
  33.     wyswietl(dane);
  34.     push(dane,6);
  35.      printf("Liczby w stosie: \n");
  36.     wyswietl(dane);
  37.     push(dane,7);
  38.      printf("Liczby w stosie: \n");
  39.     wyswietl(dane);
  40.     push(dane,8);
  41.        printf("Liczby w stosie: \n");
  42.     wyswietl(dane);
  43.     push(dane,9);
  44.        printf("Liczby w stosie: \n");
  45.     wyswietl(dane);
  46.     push(dane,10);
  47.  
  48.     printf("Liczby w stosie: \n");
  49.     wyswietl(dane);
  50.  
  51.  
  52.  
  53. free(dane);
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement