Keep track of the lowest numbers in an array

前端 未结 4 1463
旧巷少年郎
旧巷少年郎 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:29

    One way to sort lowest numbers in array

    // let array be of size x
     int arr[]=new int[x];
    
    // Now,assign some values to array
    
    int smallest=arr[0]; // assign any value to smallest
    
    // logic
    
      for( int i=0; i < arr.length; i++ ) {
         if( smallest > arr[i] ) {
           smallest = arr[i];
         }
       }
    
       System.out.println(smallest); // gets the smallest number out on output stream
    

提交回复
热议问题