参考代码:
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++代码)(直接输出样例hhhh)浏览:1158 |
C语言训练-求PI* (C语言代码)(正确结果竟然是谜一样的3.141591)浏览:1301 |
K-进制数 (C++代码)浏览:858 |
川哥的吩咐 (C语言代码)浏览:875 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:880 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:702 |
三角形 (C++代码)记忆化搜索浏览:1234 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:543 |
整数平均值 (C语言代码)浏览:786 |
简单的a+b (C语言代码)浏览:830 |