阅读背景:

如何获取2D数组中元素的索引?

来源:互联网 
int[][] triangle = {  
                              {75},
                             {87,64}, //If index is 0, then start from j = 0 in 3rd row (24, 56, 88)
                               {24, 56, 88}, // if index is 2 then start from j = 2 in 4th row (43, 45, 67, 76),  and compare 67 and 76, and find the max
                               {43, 45, 67, 76}
  };

  for (int i = 0; i < array.length - 1; i++) {
   for (int j = 0; j < array[i].length; j++) {
        int  x = triangle[i][j];
         int y = triangle[i][j + 1];
            int max = Math.max(x, y);
      if (someCondition) {
          //getTheIndexOFMaxVariable (Here If I am looking for 64 then it should give me 1 as an index)
       }
    }
 }
int[][] triangle = {  
                        



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: