JAVA simple grouping algorithm implementation

  • 2020-04-01 01:27:38
  • OfStack


import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;

 
 public class Group {
         public static void main(String[] args)
         {
             int[] i ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
             int len = i.length;
             int count = len/5;
             //A set of 4000
             for(int j = 0 ; j < count ; j++)
             {
                 for(int m = 0 ; m<5;m++)
                     System.out.println(i[m+j*5]+"****"+m+j*5);
                 //For processing
             }
             //The rest is not enough for 4000
             for(int m = 0 ; m<len%5;m++)
                 System.out.println(i[m+count*5]+"====="+m+count*5);
         }
     }       

Related articles: