nyoj-2-括号配对问题

 1 #include<stdio.h>
 2 #include<string.h>
 3 struct ZH
 4 {
 5     char name[10010];
 6     int top;
 7 }br;
 8 int main()
 9 {
10     int n,len,i;
11     char a[10010];
12     while(scanf("%d",&n)!=EOF)
13     {
14         scanf("%s",a);
15         len=strlen(a);
16         br.top=0;
17         for(i=0;i<len;i++)
18         {
19             //puts(br.name);
20             //puts(a);
21             if(br.top>0)
22             {
23                 if(a[i]==')'&&br.name[br.top]=='('||a[i]==']'&&br.name[br.top]=='[')
24                     br.top--;
25                 else
26                     br.name[++br.top]=a[i];
27             }
28             else
29                 br.name[++br.top]=a[i];
30         }
31         printf(br.top?"No
":"Yes
");
32     }
33     return 0;
34 }
原文地址:https://www.cnblogs.com/nylg-haozi/p/3184081.html