解题思路:
注意事项:
参考代码:
#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 人评分
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:1031 |
C语言程序设计教程(第三版)课后习题10.1 (Java代码)浏览:1447 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:604 |
淘淘的名单 (C语言代码)浏览:1104 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:936 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:1428 |
星期判断机 (C语言代码)浏览:859 |
大神老白 (C语言代码)浏览:601 |
C语言程序设计教程(第三版)课后习题12.6 (C语言代码)浏览:661 |
矩阵转置 (C语言代码)浏览:783 |