我写出来了? for (int j = 0; j < n; j++) { if( map[0][j] != 1) { dp[0][j] = dp[0][j - 1] + dp[1][j - 1]; } if( map[1][j] != 1) { dp[1][j] = dp[0][j - 1] + dp[1][j - 1]; } } System.out.println(dp[1][n-1]); 不知道对不对。。一个for循环搞定,笔试我一道都没做出😂