参考代码:
import java.util.Scanner; public class Main { static String in; static int index = -1; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); in = scanner.next(); System.out.print(dfs()); } public static int dfs() { int max = 0; int current = 0; while(index < in.length() - 1) { index++; if(in.charAt(index) == 'x') current++; else if(in.charAt(index) == '(') current += dfs(); else if(in.charAt(index) == ')') break; else if(in.charAt(index) == '|') { max = Math.max(current, max); current = 0; } } return Math.max(max, current); } }
0.0分
5 人评分
C语言程序设计教程(第三版)课后习题7.2 (Java代码)浏览:687 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:436 |
母牛的故事 (C语言代码)浏览:959 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:652 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:508 |
【明明的随机数】 (C语言代码)浏览:804 |
1035 题解浏览:786 |
Quadratic Equation (C语言代码)浏览:989 |
一元一次方程 (C语言代码)浏览:4075 |
交换Easy (C语言代码)浏览:764 |