Nothing to do, write a bubble sort to play (in reverse order, in descending order)

 . 1   public int [] GetPoPo ( the params int [] INTS)  2         {  . 3 // length  4             
 
              
               int  Leng  =  ints.Length;
 . 5   // swap flag  6             
               BOOL  Exchange;
 . 7   // up to n-1 times sort  8             
               for  ( int  n-  = . 1 ; n-  <  Leng; n- ++ )  . 9             { 10                 Exchange  = to false ; . 11 // from the bubbles float to the bottom 12  
 
   
                  
                   for  ( int  I  =  Leng - . 1 ; I  > 0 ; I - ) 13 is                 { 14 // If bubbles 15  
 
                      
                       IF  (INTS [I]  >  INTS [I  - . 1 ]) // To sort order, to: INTS [I] <INTS [I -. 1] 16  
                      {
. 17   int  the nonce  =  INTS [I  - . 1 ]; 18 is                         INTS [I  - . 1 =  INTS [I]; . 19                         INTS [I]  =  the nonce; 20 is // tag floats over 21                           
   
 
                          
                          Exchange  = to true ; 22 is                     } 23 is                 } 24 // If no bubbles float up in advance out of the loop 25  
 
 
                  
                   if  ( ! exchange)  break ;
26              }
27               return  ints;
28          }

Reproduced in: https: //www.cnblogs.com/dagecc/archive/2006/11/23/570211.html

Guess you like

Origin blog.csdn.net/weixin_34080571/article/details/93829584
Recommended