给定一串字符,不超过100个字符,可能包括括号、数字、字母、标点符号、空格,编程检查这一串字符中的( ) ,[ ],{ }是否匹配。
输入格式:
输入在一行中给出一行字符串,不超过100个字符,可能包括括号、数字、字母、标点符号、空格。
输出格式:
如果括号配对,输出yes,否则输出no。
输入样例1:
sin(10+20)
输出样例1:
yes
输入样例2:
{[}]
输出样例2:
no
代码如下(示例):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXSIZE 5
typedef char ElemType;
typedef struct{
ElemType *fh;
int length;
}SqList;
/*
* 括号匹配
* @author Ethereal
* 2020.11.23
*/
int top=-1;//top变量时刻表示栈顶元素所在位置
void push(char * fh,int elem){
fh[++top]=elem;
}
void pop(char* fh){