Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. struct stiva_array{
  4. int size;
  5. int max;
  6. int *elemente;
  7. int varf;};
  8.  
  9.  
  10. typedef struct nod{
  11. int val;
  12. struct nod*next;
  13. }nod;
  14.  
  15. typedef struct stiva{
  16. nod * varf;
  17. int size,max;}stiva;
  18.  
  19. void push(stiva * s, int v)
  20. {nod * tmp=malloc(sizeof(nod));
  21. tmp->val=v;
  22. tmp->next=s->varf;
  23. s->varf=tmp;
  24. }
  25.  
  26.  
  27.  
  28. stiva * creare_stiva(int max)
  29. {stiva * lsk=malloc(sizeof(stiva));
  30. lsk->varf=NULL;
  31. lsk->size=0;
  32. lsk->max=max;
  33. return lsk;
  34.  
  35. }
  36.  
  37. void afisare(nod*prim){
  38. nod*p=prim;
  39. while(p!=NULL)
  40. {printf("%d ",p->val);
  41. p=p->next;
  42.  
  43. }
  44.  
  45. }
  46.  
  47.  
  48.  
  49.  
  50. int main()
  51. {stiva * s=creare_stiva(10);
  52. push(s,1);
  53. push(s,2);
  54. push(s,3);
  55. push(s,4);
  56. afisare(s->varf);
  57.  
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement