提交时间:2023-08-22 16:17:11

运行 ID: 99333

#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { char s[256],stack[256],top=0; gets(s); if(strlen(s)%2) { cout<<"Wrong"; return 0; } for(int i=0;i<strlen(s);i++) { if(s[i]=='('||s[i]=='['||s[i]=='{') { stack[top++]=s[i]; } else { if(s[i]-(s[i]==')'?1:2)==stack[top-1]) stack[--top]='\0'; else { cout<<"Wrong"; return 0; } } } cout<<"OK"; return 0; }