JAVA简单分组的算法实现_java

分享到:

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

 /**
  * Created with IntelliJ IDEA.
  * User: dell
  * Date: 13-3-5
  * Time: 下午8:38
  * To change this template use File | Settings | File Templates.
  */
 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;
             //够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);
                 //进行处理
             }
             //剩下的不够4000的处理
             for(int m = 0 ; m<len%5;m++)
                 System.out.println(i[m+count*5]+"====="+m+count*5);
         }
     }      
昵    称:
验证码: