#include #include #include typedef char TYPE; struct node { TYPE data; struct node *next; }; struct stack { struct node *head; }; typedef struct stack * Stack; void push(Stack s, TYPE e) { node * temp = (node *) malloc(sizeof(struct node)); if(temp == NULL) { printf("Error : Cannot Allocate Memory."); } temp->data = e; temp->next = s->head; s->head = temp; } int isEmpty(Stack s) { return (s->head==NULL); } TYPE pop(Stack s) { if(isEmpty(s)) { printf("Error : Stack is Empty."); return -1; } node* temp = s->head->next; TYPE result = s->head->data; free(s->head); s->head = temp; return result; } void clear(Stack s) { while (!isEmpty(s)) pop(s); } TYPE top(Stack s) { if (!isEmpty(s)) return s->head->data; else { printf("Error: Stack is empty!\n"); return -1; } } void initStack(Stack s) { s->head = NULL; } int isCorrect(char* str) { Stack s = (Stack) malloc (sizeof(struct node)); initStack(s); int i; for (i=0; i