#include <stdio.h>
typedef struct listNode *listPointer;
typedef struct {
int posotion;
char symbol;
listPointer link;
}listNode;
void push(char symb, int posotion){
listNode temp = ;
}
int main() {
//Initial Value
int position = 0;
char symb;
listNode *top=NULL;
while((symb=getchar())!='\n'){
//left parenthesis
if(symb=='('||symb=='['){
char left_parenthesis = symb;
push(left_parenthesis,position);
}
//right parenthesis
else if(symb==')'||symb==']'){
listPointer left_parenthesis=pop();
char right_parenthesis=symb;
//small parenthesis match
if(*left_parenthesis->symbol=='(' && symb==')'){
printf("(%d,%d)",left_parenthesis.position,position);
}
//middle parenthesis match
else if(left_parenthesis->symbol=='[' && symb==']'){
printf("(%d,%d)",left_parenthesis.position,position);
}
//small parenthesis not match
else if(left_parenthesis->symbol=='(' && symb==']'){
printf("位置編號%d的右括弧]沒有可配對的左括弧[",position);
}
//middle parenthesis not match
else if(left_parenthesis->symbol=='[' && symb==')'){
printf("位置編號%d的右括弧)沒有可配對的左括弧(",position);
}
}
posotion++;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: