Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stddef.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6.  
  7. typedef struct stos_tag {
  8.  
  9.   int dane;
  10.   struct stos_tag *nast;
  11.  
  12. } t_stos;
  13.  
  14. int push(t_stos *stos, int *dana)
  15. {
  16.   t_stos *nowy;
  17.  
  18.   nowy= (t_stos*)malloc(sizeof(t_stos));
  19.  
  20.     if nowy == NULL
  21.         return -1;
  22.  
  23.   nowy->dane = *dana;
  24.   nowy->nast = stos;
  25.   stos = nowy;
  26.  
  27.  return 0;
  28. }
  29.  
  30. int pop(t_stos *stos, int *dana)
  31. { t_stos *wsk;
  32.  
  33.   if(stos!=NULL)
  34.   {
  35.  
  36.     wsk=stos;
  37.     *dana = stos-> dane;
  38.     stos=stos->nast;
  39.     free(wsk);
  40.     return 0;
  41.   }
  42.  
  43.     return -1;
  44.  
  45. }
  46.  
  47. int empty(t_stos *stos)
  48. {
  49.   if(stos==NULL)
  50.     return 1;
  51.   else
  52.     return 0;
  53. }
  54.  
  55.  
  56. int main()
  57. {
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement