zoukankan      html  css  js  c++  java
  • 大数组分页成小数组

    public static void mod()
        {
            //源数组
            int x[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14};
            //每组多少个
            int len = 5 ;
            //数组数量
            int y = x.length;
            int left  = y%len ;
            int size  = left==0?y/len:y/len+1;
            //当前页码
            int index = 1 ;
            for(int i=1;i<=size;i++)
            {
                //新数组 数量
                int tempsize  = len ;
                if(i==size && left>0) 
                {
                    tempsize = left ;
                }
                //新数组
                Integer []temparray = new Integer[tempsize];
                for(int j=0;j<tempsize;j++)
                {
                    temparray [j] = x[len*(index-1)+j];
                }
                //打印新数组
                for(int k=0;k<temparray.length;k++)
                {
                    
                    Debug.debug(temparray[k]+"");
                    
                    
                }
                Debug.debug("=====================");
                index++;
            }
        }
  • 相关阅读:
    Ubuntu下 实现Linux与Windows的互相复制与粘贴
    bzoj2426
    bzoj1835
    bzoj1197
    bzoj1049
    bzoj2893
    bzoj1820
    bzoj1819
    bzoj1455
    bzoj3689
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5493883.html
Copyright © 2011-2022 走看看