MasssA


私信TA

用户名:1294309339

访问量:34875

签 名:

城市学院的渣渣

等  级
排  名 104
经  验 7932
参赛次数 6
文章发表 73
年  龄 0
在职情况 学生
学  校 城市学院的渣渣
专  业

  自我简介:

城市学院的渣渣

解题思路:

注意事项:

参考代码:

#include <bits/stdc++.h>
using namespace std;
int len,pos=0;
string str;
int dfs()
{
    int num=0,maxx=0;
    while(pos<len)
    {
        if(str[pos]=='(')
        {
            pos++; num+=dfs();
        }
        else if(str[pos]==')') {
            pos++; break;
            
        }
        else if(str[pos]=='|') {
            pos++; maxx=max(num,maxx);
            num=0;

        }
        else {
            pos++; num++;
        }
        
    } maxx=max(num,maxx);
    return maxx;
    
}
int main()
{
    cin>>str;
    len=str.length();
    printf("%d\n",dfs());
    return 0;
    
}

 

0.0分

5 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区