我有一個2維數組的字符串,我想查找每13個元素的最大值。獲取數組各部分的最小值和最大值
數組是數組[String date] [String price1] [String price2]。 我想最高的價格1 0-12,然後price1 1-13,然後price1 2-14等
{1,2,3,4,5,6,7,8,9,10, 9,8,11,6,5,4,3,2,1}
13 {1,2,3,4,5,6,7,8,9,10,9, 8,7}將返回10
的13 {2,3,4,5,6,7,8,9,10,9,8,7,11}第二列表將返回11
13 {3,4,5,6,7,8,9,10,9,8,7,11,6}的第三列表將返回11 等
編輯 抱歉,這有點令人困惑,數組是字符串的二維數組,第一列是日期,第二和第三列是雙倍數。我想找到第二列的最大值和第三列的最小值。
這裏是我已經得到了:
String str = "";
for(int ii = 1 ; ii < array.length ; ii++){
str = str+array[ii][2]+",";
if(ii==13){
str = Math.max(str.substring(0, str.lastIndexOf(',', str.lastIndexOf(',') - 1)));
System.out.println(str);
}
}
請包括到目前爲止什麼都試過... – 2011-12-15 03:11:56