#include<iostream>
#include<cstdlib>
using namespace std;
struct node
{
int data;
node *next;
};
struct lns
{
node *top;
};
node *push(node *l,int k)
{
node *t,*q;
t=l;
t=new(node);
t->data=k;
t->next=NULL;
return l;
}
int pop(node *l)
{
node *q;int k;
q=l;
k=q->data;
q=q->next;
l=q;
return k;
}
int main()
{
lns *s;
s=NULL;
node *t,*l;
int k,i;
cout<<"Enter no's...Press -1 for aborting...\n";
cin>>k;
while(k!=-1)
{
s=new(lns);
s->top=NULL;
l=push(s->top,k);
cin>>k;
}
for(i=1;i<count;i++)
{
k=pop(l);
cout<<k<<endl;
}
}
#include<cstdlib>
using namespace std;
struct node
{
int data;
node *next;
};
struct lns
{
node *top;
};
node *push(node *l,int k)
{
node *t,*q;
t=l;
t=new(node);
t->data=k;
t->next=NULL;
return l;
}
int pop(node *l)
{
node *q;int k;
q=l;
k=q->data;
q=q->next;
l=q;
return k;
}
int main()
{
lns *s;
s=NULL;
node *t,*l;
int k,i;
cout<<"Enter no's...Press -1 for aborting...\n";
cin>>k;
while(k!=-1)
{
s=new(lns);
s->top=NULL;
l=push(s->top,k);
cin>>k;
}
for(i=1;i<count;i++)
{
k=pop(l);
cout<<k<<endl;
}
}
No comments:
Post a Comment