文章

2

粉丝

290

获赞

1

访问

14.1k

头像
简单思路,建立一个栈用来判断优先级
P1067 中山大学2019年机试题
发布于2021年2月15日 15:57
阅读数 6.4k

#include<bits/stdc++.h>
using namespace std;
#include<string.h>

int main(){

    int n;
    while(cin>>n){

   char ch[260];

   for(int j=0;j<n;j++){

   cin>>ch;

   stack<char> s;
   stack<int> flag;

   int len=strlen(ch);

   int cnt=0;


   for(int i=0;i<len;i++){
        int now;
        if(ch[i]=='<'){
            now=1;
        }
        else if(ch[i]=='(')
            now=2;
        else if(ch[i]=='[')
            now=3;
        else if(ch[i]=='{')
            now=4;
        else
        &...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发