参考代码:
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二级辅导-分段函数 (C语言代码)浏览:843 |
C语言程序设计教程(第三版)课后习题12.6 (C语言代码)浏览:791 |
简单的a+b (C语言代码)浏览:489 |
2005年春浙江省计算机等级考试二级C 编程题(3) (C语言代码)浏览:388 |
求组合数 (C语言代码)浏览:1152 |
用筛法求之N内的素数。 (C语言代码)浏览:802 |
1054题解浏览:460 |
C二级辅导-计负均正 (C语言代码)浏览:480 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:582 |
简单的a+b (C语言代码)浏览:531 |