我正在尝试打印输出,该输出将找到最大数量,并且还打印数组的索引号。我可以打印最大数量,但无法打印索引编号。
public static int findMax(int[] allNumbers) {
int maxValue = allNumbers[0];
for (int i = 1; i < allNumbers.length; i++) {
if (allNumbers[i] > maxValue) {
maxValue = allNumbers[i];
}
}
return (int) maxValue;
}
我的数组:
int[] allNumbers = new int[inpNum];
我可以拨打以下电话
findMax(number)
答案 0 :(得分:2)
您可以返回最大值和索引的数组:
SELECT town FROM
(SELECT DISTINCT * FROM towns) t
INNER JOIN codes ON ccde=code GROUP BY town
HAVING COUNT(*)=(SELECT DISTINCT COUNT(*) FROM codes)