解题思路:
注意事项:
参考代码:
#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 人评分
点我有惊喜!你懂得!浏览:972 |
C二级辅导-同因查找 (C语言代码)浏览:585 |
剪刀石头布 (C语言代码)不知道怎么直接在scanf中用枚举变量浏览:1315 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:574 |
C语言训练-尼科彻斯定理 (C语言代码)浏览:468 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1311 |
WU-图形输出 (C++代码)浏览:802 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:632 |
回文数字 (C语言代码)浏览:2510 |
A+B for Input-Output Practice (V) (C语言代码)浏览:466 |