期望得分:100+0+30=130

实际得分:100+36.5+0=136.5

T3 一个变量写混了,丢了30。。

 

2017北京国庆刷题Day3 afternoon

模拟栈

#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;
}
View Code

相关文章:

  • 2021-10-25
  • 2021-12-02
  • 2022-02-13
  • 2021-10-29
  • 2021-11-04
  • 2021-11-13
  • 2021-08-23
  • 2022-01-24
猜你喜欢
  • 2022-02-04
  • 2021-07-14
  • 2021-12-11
  • 2022-02-08
  • 2021-07-30
  • 2022-02-11
  • 2021-07-30
相关资源
相似解决方案