中兴笔试第一题给的例子全部都能通过,但提交case通过率为0,实在不知道错在哪,有参加了笔试的大佬能帮忙看看错在哪吗?
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); int n = sc.nextInt(); int[][] nums = new int[m][n]; for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ nums[i][j] = sc.nextInt(); } } int max = 0; for(int i = 1;i<m-1;i++){ for(int j = 1;j<n-1;j++){ int sum = getSum(nums, i, j); max = Math.max(max,sum); } } System.out.println(max); } public static int getSum(int[][] nums,int i,int j){ int sum = nums[i][j] + nums[i-1][j] + nums[i+1][j] + nums[i][j-1] + nums[i][j+1]; return sum; }
全部评论
(13) 回帖