Advertisement
selkieautopsy13

Untitled

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