高手看看这个程序
#include "stdafx.h"#include "iostream.h"
#include "stdio.h"
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct{
int *elem;
int top;
int stacksize;
int incrementsize;
}SqStack;
void InitStack_Sq(SqStack &S,int maxsize=STACK_INIT_SIZE,int increment=STACKINCREMENT)
{
S.elem=new int[maxsize];
S.top=-1;
S.stacksize=maxsize;
S.incrementsize=increment;
}
void IncrementStackSize(SqStack &S)
{int i;
int *a;
a=new int[S.stacksize+S.incrementsize];
for(i=0;i<=S.top;i++)
a[i]=S.elem[i];
delete []S.elem;
S.elem=a;
S.stacksize+=S.incrementsize;
}
void Push_Sq(SqStack &S, char e)
{if(S.top=S.stacksize) IncrementStackSize(S);
S.elem[++S.top]=e;
}
void OverflowMessage(char *s)
{cout<<s<<endl;
}
char GetTop_Sq(SqStack S,char &e)
{if(S.top==-1) OverflowMessage("顺序栈下溢!");
e=S.elem[S.top];
return e;}
char Pop_Sq(SqStack &S,char &e)
{if(S.top==-1) OverflowMessage("顺序栈S下溢!");
e=S.elem[S.top--];
return e;}
bool abab(SqStack S)
{
char ch;
char e;
int state;
InitStack_Sq(S);
Push_Sq(S,'#');
ch=getchar();
state=1;
while(ch!='\n'&&state)
{if(ch=='('||ch=='['||ch=='{')
Push_Sq(S,ch);
if(ch==')'||ch==']'||ch=='}')
{if(GetTop_Sq(S,e)=='#')
state=0;
else if(GetTop_Sq(S,e)==ch)
Pop_Sq(S,e);
ch=getchar();}
if(GetTop_Sq(S,e)!='#') state=0;
if(state) return true;
else return false;
}
int main(int argc, char* argv[])
{SqStack S;
abab(S);
return 0;
}
判断输入的大小中括号是否配对的问题。。。。。。。。。我知道我主函数写错了。。我不知道该怎么写