期望得分:100+0+30=130
实际得分:100+36.5+0=136.5
T3 一个变量写混了,丢了30。。
模拟栈
#include<cstdio> #include<cstring> using namespace std; #define N 10001 char s[N]; int st[N],top; int main() { freopen("a.in","r",stdin); freopen("a.out","w",stdout); scanf("%s",s); int len=strlen(s); for(int i=0;i<len;i++) if(s[i]=='(') st[++top]=1; else if(s[i]=='[') st[++top]=2; else if(s[i]=='{') st[++top]=3; else if(s[i]==')') { if(st[top]==1) top--; else { printf("Wrong");return 0; } } else if(s[i]==']') { if(st[top]==2) top--; else { printf("Wrong"); return 0; } } else { if(st[top]==3) top--; else { printf("Wrong"); return 0; } } if(top) printf("Wrong"); else printf("OK"); return 0; }