#include<bits/stdc++.h>
using namespace std;
int *a, s;
int t = -1;
void push(int v)
{
if(s>t)
{
t++;
a[t] = v;
}
else
{
cout << "Stack is Full -_-" << endl << endl;
}
}
void pop()
{
if(t>=0)
{
t--;
}
else
{
cout << "Can't PoP -_-" << endl << endl;
}
}
void print()
{
int i;
cout << "Current Stack :: ";
for(i=0;i<=t;i++)
{
cout << a[i] << " ";
}
cout << endl << endl;
}
int main()
{
cout << "Enter Array Size :: ";
cin >> s;
a = (int*) malloc(s*sizeof(int));
push(1);
push(2);
push(3);
push(4);
push(5);
push(6);
print();
pop();
pop();
pop();
pop();
pop();
pop();
print();
return 0;
}
using namespace std;
int *a, s;
int t = -1;
void push(int v)
{
if(s>t)
{
t++;
a[t] = v;
}
else
{
cout << "Stack is Full -_-" << endl << endl;
}
}
void pop()
{
if(t>=0)
{
t--;
}
else
{
cout << "Can't PoP -_-" << endl << endl;
}
}
void print()
{
int i;
cout << "Current Stack :: ";
for(i=0;i<=t;i++)
{
cout << a[i] << " ";
}
cout << endl << endl;
}
int main()
{
cout << "Enter Array Size :: ";
cin >> s;
a = (int*) malloc(s*sizeof(int));
push(1);
push(2);
push(3);
push(4);
push(5);
push(6);
print();
pop();
pop();
pop();
pop();
pop();
pop();
print();
return 0;
}
Comments
Post a Comment