游客已登陆 (0)未知
笔行证 257310
昵称 kuan 
笔贝 Score1
加为好友 发送短信
<< << 2009 一月 >> >>
123
45678910
11121314151617
18192021222324
25262728293031

访问计数:27082
本文:370 今天:1 本月 129

本地音乐播放器



 
       栈顺序存储结构
2007-04-12 晴



struct Stack
{
ElemType stack[StacckMaxSize];
int top;
};


void InitStack(Stack &S)
{
S.top = -1;
}

void ClearStack(Stack &S)
{
S.top = -1;
}

void StackEmpty(Stack &S)
{
return S.top == -1;
}

ElemType Peek(Stack &S)
{
if(S.top == -1)
{
cerr<<"Stack is empty!"<<endl;
exit(1);
}
return S.stack[S.top];
}

void Push(Stack &S, const ElemType &item)
{
if(S.top == StackMaxSize-1)
{
cerr<<"Stack overflow!"<<endl;
exit(1);
}
S.top++;
S.stack[S.top] = item;
}

ElemType Pop(Stack &S)
{
if(S.top == -1)
{
cerr<<"Stack is empty!"<<endl;
exit(1);
}
ElemType temp S.stack[S.top];
S.top--;
return temp;
}

int StackFull(Stack &S)
{
return S.top == StackMaxSize-1;
}.
# posted by kuan @ 2007-04-12 13:10:13 评论(0)
 








 
笔 名:
*
评 论:
最多1000字。当前字数:0
*
联系方式: