分类：电脑/网络-互联网
问题：用数组实现栈的功能的C语言代码？ 
回答：栈在处理数组上面真的很方便，这是栈的基础方法//顺序栈的实现stack.cpp#include "stack.h"Status SqStack::InitStack(SqStack **S){ (*S)=(SqStack *) malloc(sizeof(SqStack));  (*S)->base=(SElemType *)malloc(STACKSIZE *sizeof(SElemType));  if(!(*S)->base) exit(OVERFLOW);  (*S)->top=(*S)->base;  (*S)->stacksize=0;  return 1;}Status SqStack::DestroyStack(){free(base);return 1;}Status SqStack::ClearStack(){stacksize=0;return 1;}bool SqStack::StackEmpty(){ if(stacksize==0) return true;  else return false;}int SqStack::StackLength(){ return stacksize;}SElemType SqStack::GetTop(){ if(top==base)   {cerr<<"空栈!\n";exit(1);}  return *(top-1);}Status SqStack::Push(SElemType e){ *(top++)=e;stacksize++;  return 1;}SElemType SqStack::Pop(SElemType *e){ if(top==base)   {cerr<<"空栈!\n";exit(1);}  *e=*--top;  stacksize--;  return *e;}void SqStack::StackTraverse(void (*visit)(SElemType *)){while(top!=base){   stacksize--;visit(--top);}}