Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我的程序自己运行时候是对的,怎么一提交就有错,那位高手能指点一下,本人不胜感激!(JAVA代码)import java.util.Scanner; public class Main { public static void main(String[] arg) { Scanner cin = new Scanner(System.in); int row = cin.nextInt(); int col = cin.nextInt(); double[][] hight = new double[row + 2][col + 2]; int[][] lian = new int[row + 2][col + 2]; for (int j = 0; j < col + 2; j++) { lian[0][j] = lian[row + 1][j] = 0; hight[0][j] = hight[row + 1][j] = 1050; } for (int i = 0; i < row + 2; i++) { lian[i][0] = lian[i][col + 1] = 0; hight[i][0] = hight[i][col + 1] = 1050; } for (int i = 1; i < row + 1; i++) { for (int j = 1; j < col + 1; j++) { hight[i][j] = cin.nextDouble(); lian[i][j] = 0; } } int zui = 0; for (int i = 1; i < row + 1; i++) { for (int j = 1; j < col + 1; j++) { int temp = piao(hight, lian, i, j); if (zui < temp) zui = temp; } } System.out.println(zui); } public static int piao(double[][] h, int[][] lian, int i, int j) { if (lian[i][j] == 0) { int temp1 = 1, temp2 = 1, temp3 = 1, temp4 = 1; if (h[i][j] > h[i][j + 1]) { if (lian[i][j + 1] != 0) temp1 = lian[i][j + 1] + 1; else temp1 = piao(h, lian, i, j + 1) + 1; } if (h[i][j] > h[i - 1][j]) { if (lian[i - 1][j] != 0) temp2 = lian[i - 1][j] + 1; else temp2 = piao(h, lian, i - 1, j) + 1; } if (h[i][j] > h[i][j - 1]) { if (lian[i][j - 1] != 0) temp3 = lian[i][j - 1] + 1; else temp3 = piao(h, lian, i, j - 1) + 1; } if (h[i][j] > h[i + 1][j]) { if (lian[i + 1][j] != 0) temp4 = lian[i + 1][j] + 1; else temp4 = piao(h, lian, i + 1, j) + 1; } if (temp2 > temp1) temp1 = temp2; if (temp4 > temp3) temp3 = temp4; if (temp1 < temp3) temp1 = temp3; lian[i][j] = temp1; } return lian[i][j]; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator