程序如下:
#include<iostream.h>
#include<string.h>
class stack
{
public:
    stack(){}
    stack(int sz):size(sz),n(0),k(0),top(0),bottom(0)
    {
        s=new char[100];
        s[99]='\0';
        m=new char[100];
    }
    void push(char c)
    {
        if(top-bottom>=size)
            cout<<"full!"<<endl;
        else
        {
        s[top]=c;
        top=top+1;
        }
    }
        
    char pop()
    {
        if(top<=bottom)
            cout<<"empty!"<<endl;
        else
        {
            return s[top-1];
            top=top-1;
        }
    }
    void pick()
    {
        for(int i=0;i<top;i++)
        {
            if(s[i]=='{'&&s[i]=='('&&s[i]=='['&&s[i]==']'&&s[i]==')'&&s[i]=='}')
            {
                m[n]=s[i];
                n=n+1;
            }
        }
    }
    bool fb(char a,char b)
    {
        if((a=='('&&b==')')||(a=='['&&b==']')||(a=='{'&&b=='}'))        
            return true;
        else
            return false;
    }
    bool pipei()
    {
        if(n%2==0)
        {
        for(int j=0;j<n;j++)
        {
            if(fb(m[j],m[n-j-1]))
            {
                k=k+1;
            }    
        }
        if(k==n/2)
        {
            return true;
        }
        else 
            return false;
        }
        else
            return false;
    }
    void disp()
    {
        for(int i=bottom;i<top;i++)
        {
            cout<<s[i];
        }
        cout<<endl;
    }
private:
    int bottom;
    int top;
    int n;
    int k;
    int size;
    char *s;
    char *m;
};
void main()
{
    stack a(10);
    a.push(')');
    a.push('[');
    a.push('(');
    a.push(')');
    a.push(']');
    a.push('}');
    a.disp();
    if(a.pipei())
    {
        cout<<"right!"<<endl;
    }
    else
    {
        cout<<"wrong!"<<endl;
    }
}
这样匹配应该显示wrong 为什么是right啊
肯定是哪个地方错了 我没找到 大家按照我的这个思路 帮我找找错误吧
谢谢大家的指教了 
                

 
											





 
	    

