Nó ra toàn stack is empty ạ.
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<conio.h>
using namespace std;
int current_size = -1;
const int max_size = 100;
int stack[max_size];
bool isEmpty()
{
return (current_size = -1);
}
bool isFull()
{
return(current_size==max_size);
}
void push(int data)
{
if(!isFull())
{
current_size++;
stack[current_size]=data;
}
else
{
cout<<"Stack full";
}
}
int top()
{
if(!isEmpty)
{
int data = stack[current_size];
//current_size--;
return data;
}
else
{
cout<<"Stack is empty ! "<<"\n";
}
}
int pop()
{
if(!isEmpty)
{
int data = stack[current_size];
current_size--;
return data;
}
else
{
cout<<"Stack is empty ! "<<"\n";
}
}
int main()
{
push(100);
push(-255);
push(-25);
cout<<"top : "<<top()<<"\n";
pop();
cout<<"top : "<<top()<<"\n";
while (!isEmpty())
{
int data = pop();
cout<<data<<" <-- ";
}
cout<<"\n";
system("pause");
return 0;
}