NganXep
//ke tiep
#include<iostream>
#include<stdio.h>
using namespace std;
class Stack
{
private:
enum{size=32};
int S[size];
int T;
public:
Stack();
void push(int x);
int pop();
bool isEmpty();
};
int main()
{
cout<<endl;
return 0;
}
Stack::Stack():T(-1){}
void Stack::push(int x)
{
if(T==size-1)
{
cout<<"Ngan xep day!";
return;
}
S[++T] = x;
}
int Stack::pop()
{
if(T==-1)
{
cout<<"Ngan xep rong!";
return 1;
}
return S[--T];
}
bool Stack::isEmpty()
{
return T==-1;
}
// phan tan
#include<iostream>
#include<stdio.h>
using namespace std;
class Stack
{
private:
struct node
{
int infor;
node *link;
} *T;
public:
Stack();
~Stack();
void push(int x);
int pop();
bool isEmpty();
};
int main()
{
cout<<endl;
return 0;
}
Stack::Stack():T(NULL){}
Stack::~Stack()
{
while(T)
{
node *P = T;
T = T->link;
delete P;
}
}
void Stack::push(int x)
{
node *N = new node;
N->infor = x;
N->link = T;
T = N;
}
int Stack::pop()
{
if(T==NULL)
{
cout<<"ngan xep rong!";
return 1;
}
int tg = T->infor;
node *P = T;
T = T->link;
delete P;
return tg;
}
bool Stack::isEmpty()
{
return T==NULL;
}
Last updated