文章
145
粉丝
217
获赞
21
访问
85.0k
#include <stdio.h>
#include <string.h>
int JudgeMatch(char *s)
{
char t[500];
int top = -1,i = 0;
while(s[i] != '\0')
{
while(s[i] == '[' || s[i] == '(')
t[++top] = s[i++];
if((s[i] == ')' && t[top] == '(') || (s[i] == ']' && t[top] == '['))
i++,top--;
else return 0;
}
return 1;
}
int main()
{
char s[1000];
gets(s);
if(JudgeMatch(s)) printf("YES\n");
else printf("NO\n");
return 0;
}
登录后发布评论
暂无评论,来抢沙发