标签:
2 3
1 #include<stdio.h> 2 int main() 3 { 4 int a,b; 5 scanf("%d%d",&a,&b); 6 printf("%d\n",a+b); 7 }
3 [(]) (]) ([[]()])
No No Yes
代码:
1 #include <iostream> 2 #include <string.h> 3 using namespace std; 4 5 int main() 6 { 7 char ch[10000],s[5000]; 8 int n,i,top=0; 9 cin>>n; 10 if(n<=0 || n>100) 11 return -1; 12 while(n--) 13 { 14 cin>>ch; 15 for(i=0;i<strlen(ch);i++) 16 { 17 if(ch[i]==‘[‘ || ch[i]==‘(‘) 18 s[top++]=ch[i]; 19 else 20 { 21 if((ch[i]==‘)‘ && s[top-1]==‘(‘) || (ch[i]==‘]‘ && s[top-1]==‘[‘)) 22 top--; 23 else 24 { 25 cout<<"No"<<endl; 26 break; 27 } 28 } 29 } 30 if(strlen(ch)!=0) 31 { 32 if(i==strlen(ch)&&top==0) 33 cout<<"Yes"<<endl; 34 } 35 else 36 n++; 37 top=0; 38 39 } 40 41 } 42
标签:
原文地址:http://www.cnblogs.com/bxyan/p/4627056.html