خرید بک لینک

#include iostream.h

#define max 30
class stack{
private:
char items[max];
int top;
public:
stack(){top=-1;}
int empty()
{retu (top==-1?1:0);}
int full()
{retu (top==(max-1)?1:0);}
void push(char x)
{
if(full())
{
cout<<"stack is full";
retu;
}
items[++top]=x;
retu;
}
char pop()
{
if(empty())
{ cout<<"stack is empty";
retu 0;
}
retu (items[top--]);
}
};
main()
{
char y;
stack s;
cout<<"Enter your char:; ";
for(int a=0;a<10;a++)
{
cin>>y;

s.push(y);
}
while(a>0)
{
cout< s.pop();

a--;
}
retu 0;
}

برچسب: نویسنده: حسین بنیادی تاريخ: سه شنبه 27 تير 1391 ساعت: 23:49

صفحه بندی