#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int a;
struct node *next;
}stack;
stack* push(stack* c,int b)
{
stack *d=NULL;
d=(stack *)malloc(1);
d->a=b;
d->next=c;
return d;
}
stack* pop(stack* a,int b)
{
stack *p;
p=a->next;
free(a);
return p;
}
void printS(stack *t)
{
while(t->next!=NULL)
{
printf("%d\n",t->a);
t=t->next;
}
}
int main(void)
{
stack *p=NULL;
p=(stack *)malloc(1);
p->next=NULL;
stack *q=NULL;
q=push(p,2);
q=push(q,4);
q=push(q,6);
q=push(q,8);
printS(q);
printf("-----------------------------\n");
q=pop(q,8);
q=pop(q,6);
q=pop(q,4);
// q=pop(q,2);
printS(q);
return 0;
}
#include<stdlib.h>
typedef struct node
{
int a;
struct node *next;
}stack;
stack* push(stack* c,int b)
{
stack *d=NULL;
d=(stack *)malloc(1);
d->a=b;
d->next=c;
return d;
}
stack* pop(stack* a,int b)
{
stack *p;
p=a->next;
free(a);
return p;
}
void printS(stack *t)
{
while(t->next!=NULL)
{
printf("%d\n",t->a);
t=t->next;
}
}
int main(void)
{
stack *p=NULL;
p=(stack *)malloc(1);
p->next=NULL;
stack *q=NULL;
q=push(p,2);
q=push(q,4);
q=push(q,6);
q=push(q,8);
printS(q);
printf("-----------------------------\n");
q=pop(q,8);
q=pop(q,6);
q=pop(q,4);
// q=pop(q,2);
printS(q);
return 0;
}