题目描述
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/6e0ec877e4e85f9648d81432ec7d30cd.jpeg)
极简解法
#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;
}
·