Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct stiva_array{
- int size;
- int max;
- int *elemente;
- int varf;};
- typedef struct nod{
- int val;
- struct nod*next;
- }nod;
- typedef struct stiva{
- nod * varf;
- int size,max;}stiva;
- void push(stiva * s, int v)
- {nod * tmp=malloc(sizeof(nod));
- tmp->val=v;
- tmp->next=s->varf;
- s->varf=tmp;
- }
- stiva * creare_stiva(int max)
- {stiva * lsk=malloc(sizeof(stiva));
- lsk->varf=NULL;
- lsk->size=0;
- lsk->max=max;
- return lsk;
- }
- void afisare(nod*prim){
- nod*p=prim;
- while(p!=NULL)
- {printf("%d ",p->val);
- p=p->next;
- }
- }
- int main()
- {stiva * s=creare_stiva(10);
- push(s,1);
- push(s,2);
- push(s,3);
- push(s,4);
- afisare(s->varf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement