参考代码:
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语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:544 |
简单的a+b (C语言代码)浏览:643 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:717 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:1052 |
C语言训练-排序问题<2> (C++代码)浏览:880 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:470 |
P1002 (C语言代码)浏览:970 |
上车人数 (C语言代码)浏览:777 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:1282 |
三角形 (C++代码)记忆化搜索浏览:1220 |