我知道我的数组有正确的信息(我判断过了),但在我的for循环中,它得到了错误的值.
int mostFrequent = 0;
int secondMost = 0;
for(int i =0;i<256;i++){
if (counter[i] > mostFrequent) {
secondMost = mostFrequent;
mostFrequent = i
} else if (counter[i] < mostFrequent && counter[i] > secondMost){
secondMost = i;
}
}
我知道我保存整数mostFrequent和secondMost作为数组的索引,这是故意的.我正在比较数组的值,但我想保存这些值的索引.正确的值应该是32和101的指数,但它是不正确的出来.