运行出现Process returned -1073740940 (0xC0000374)

表达式的括号匹配,,在运行的时候出现Process returned -1073740940 (0xC0000374),哪里有问题,如何解决

#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
    char data;
    struct Node *next;
}Node;
typedef struct stack
{
    Node *top;
    Node *bottom;
}stack;
void InitStack (stack *s)
{
    s->bottom=(Node*)malloc(sizeof(Node));
    s->bottom=s->top;
    s->bottom->next=NULL;
}
void Push (stack *s,char c)
{
    Node *p;
    p=(Node*)malloc(sizeof(Node));
    p->data=c;
    p->next=s->top->next;
    s->top->next=p;
}
void Pop (stack *s)
{
    Node *p;
    p=s->top;
    s->top=p->next;
    free (p);
}
int Empty(stack *s)
{
    return (s->top==NULL);
}
void BracketMatch (stack *s,char str[])
{
    char ch;
    for (int i=0;str[i]!='\0';i++)
    {
        switch (str[i])
        {
            case '(':
            case '[':
            case '{':
                Push (s,str[i]);
                break;
            case ')':
            case ']':
            case '}':
                if (Empty(s))
                {
                    printf("no");
                    return ;
                }
                else
                {
                    ch=s->top->data;
                    if (ch==str[i])
                    {
                        Pop(s);
                    }
                    else
                    {
                        printf("no");
                        return ;
                    }
                }
        }
    }
}
int main()
{
    stack *s;
    s=(stack*)malloc(sizeof(stack));
    char str[100];
    gets(str);
    InitStack(s);
    BracketMatch(s,str);
    if (Empty(s))
    {
        printf("yes");
    }
    else
    {
        printf("no");
    }
    return 0;
}


括号匹配不是直接用栈就能做..你这太长了而且跑起来不报错,不想看.JPG
改了一下,起码现在有输出了,剩下的我没看

#include <stdio.h>
#include <stdlib.h>
typedef struct Node
{
    char data;
    struct Node *next;
} Node;
typedef struct stack
{
    Node *top;
    Node *bottom;
} stack;
void InitStack(stack *s)
{
    s->bottom = (Node *)malloc(sizeof(Node));
    s->top = s->bottom; //写反了,你写的是bottom=top,把bottom覆盖掉了
    s->bottom->next = NULL;
}
void Push(stack *s, char c)
{
    Node *p;
    p = (Node *)malloc(sizeof(Node));
    p->data = c;
    p->next = s->top->next;
    s->top->next = p;
}
void Pop(stack *s)
{
    Node *p;
    p = s->top;
    s->top = p->next;
    free(p);
}
int Empty(stack *s)
{
    return (s->top == NULL);
}
void BracketMatch(stack *s, char str[])
{
    char ch;
    for (int i = 0; str[i] != '\0'; i++)
    {
        switch (str[i])
        {
        case '(':
        case '[':
        case '{':
            Push(s, str[i]);
            break;
        case ')':
        case ']':
        case '}':
            if (Empty(s))
            {
                printf("no");
                return;
            }
            else
            {
                ch = s->top->data;
                if (ch == str[i])
                {
                    Pop(s);
                }
                else
                {
                    printf("no");
                    return;
                }
            }
        }
    }
}
int main()
{
    stack *s;
    s = (stack *)malloc(sizeof(stack));
    char str[100];
    gets(str);
    InitStack(s);
    BracketMatch(s, str);
    if (Empty(s))
    {
        printf("yes");
    }
    else
    {
        printf("no");
    }
    return 0;
}

有帮助望采纳

应该不用这么麻烦吧?