About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

বুধবার, ২৯ অক্টোবর, ২০১৪

Stack implement by c++

# include<iostream>
# include<cstdio>
# define SIZE 20
using namespace std;

class stack
{
public:
    int a[SIZE];
    int tos; // Top of Stack

    stack();
    void push(int);
    int pop();
    int isempty();
    int isfull();
};
stack::stack()
{
    tos=0; //Initialize Top of Stack
}

int stack::isempty()
{
    return (tos==0?1:0);
}
int stack::isfull()
{
    return (tos==SIZE?1:0);
}

void stack::push(int i)
{

    if(isfull()!=1)
    {
        cout<<"Pushing "<<i<<endl;
        a[tos++]=i;

    }
    else
    {
        cout<<"Stack overflow error Possible Data Loss !";
    }
}
int stack::pop()
{
    if(isempty()!=1)
    {
        cout<<"Popping "<<a[tos-1]<<endl;
        return(a[--tos]);
    }
    else
    {
        cerr<<"Stack is empty! What to pop...!";
    }
    return 0;
}


int main()
{

    stack s;

    s.push(1);
    s.push(2);
    s.push(3);
    s.pop();
    s.pop();

   
    return 0;
}



























কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন