#include<iostream>
#include<cstdlib>
using namespace std;
class stack
{public:
int top[8],arr[8][125];
void push(int a,int b);
int pop(int a);
stack()
{top[0]=-1;
top[1]=-1;
top[2]=-1;
top[3]=-1;
top[4]=-1;
top[5]=-1;
top[6]=-1;
top[7]=-1;
}
};
void stack::push(int a,int b)
{arr[a][++top[a]]=b;
}
int stack::pop(int a)
{return arr[a][top[a]--];
}
int main()
{stack s;int i,j,k,n,p,q;
for(i=0;i<4;i++)
{cout<<"Enter the array no:";
cin>>n;
cout<<"Enter the element\n";
for(k=0;k<125;k++)
{ cin>>p;
s.push(n,p);
}
}
for(i=0;i<8;i++)
{cout<<"Enter the array:";
cin>>n;
for(j=0;j<125;j++)
{k=s.pop(n);
cout<<k<<endl;
}
}
}
#include<cstdlib>
using namespace std;
class stack
{public:
int top[8],arr[8][125];
void push(int a,int b);
int pop(int a);
stack()
{top[0]=-1;
top[1]=-1;
top[2]=-1;
top[3]=-1;
top[4]=-1;
top[5]=-1;
top[6]=-1;
top[7]=-1;
}
};
void stack::push(int a,int b)
{arr[a][++top[a]]=b;
}
int stack::pop(int a)
{return arr[a][top[a]--];
}
int main()
{stack s;int i,j,k,n,p,q;
for(i=0;i<4;i++)
{cout<<"Enter the array no:";
cin>>n;
cout<<"Enter the element\n";
for(k=0;k<125;k++)
{ cin>>p;
s.push(n,p);
}
}
for(i=0;i<8;i++)
{cout<<"Enter the array:";
cin>>n;
for(j=0;j<125;j++)
{k=s.pop(n);
cout<<k<<endl;
}
}
}
No comments:
Post a Comment