题目描述
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711225459742.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTYxOTAwNg==,size_16,color_FFFFFF,t_70)
极简解法
#include<stdio.h>
#include<string.h>
int main()
{
int depth=0,maxn=0;
char s[10000];
gets(s);
for(int i=0;i<strlen(s);i++)
{
if(s[i]=='(')
{
depth++;
if(maxn<depth)maxn=depth;
}
if(s[i]==')')depth--;
}
printf("%d\n",maxn);
printf("%d",maxn);
return 0;
}
·