Keep track of the lowest numbers in an array

前端 未结 4 1465
旧巷少年郎
旧巷少年郎 2021-01-29 12:57

I am trying to keep track of the the scores of the lowest numbers and if I find the lowest scores of those players I don\'t want them to play again in the next round. I have got

4条回答
  •  故里飘歌
    2021-01-29 13:36

    Do 2 separate loops instead. One to find lowest number, second to collect indexes.

    int minValue = 1000000; //
    for(int i =0; i< player.length; i++){
      if(player[i] < minValue){
        minValue = player[i];
      }
    }
    int j =0;
    for(int i =0; i< player.length; i++){
      if(player[i]==minValue){
        min[j]=i;
        j++;
      }
    }
    

提交回复
热议问题