Cài đặt Stack - DSLK
struct Nut{
int duLieu;
Nut *tiep;
};
struct Stack{
Nut *top;
};
void Create(Stack &s){
s.top =NULL;
}
bool Empty(Stack s){
return s.top==NULL;
}
void Push(int x, Stack &s){
Nut *p=new Nut;
p->duLieu = x;
p->tiep = s.top;
s.top=p;
}
void pop(Stack &s){
if(s.top!=NULL){
Nut *p=s.top;
s.top = p->tiep;
delete p;
}
}
int Top(Stack s){
return s.top->duLieu;
}