我是靠谱客的博主 雪白柜子,这篇文章主要介绍java 分班_新生——S型分班算法,现在分享给大家,希望可以做个参考。

package org.zttc.service;

public class DistributeClass {

public static final Boolean order =true;

public static void main(String[] args) {

//把分班后数据存入二位数组

int test[][] = divideByClass(64,8,order);

String str = "顺序";

if(!order){

str = "倒序";

}

for(int i=0;i<8;i++){

for(int j=0;j

int x = test[i][j];

if(x != 0){

System.out.println("进行"+str+"排列的结果:第"+(i+1)+"班被分配的第"+(j+1)+"位学生总体排名为:"+x+"");

}

}

}

}

public static int[][] divideByClass(int stuNum,int classNum,boolean type){

//定义一个二维数组,初始化容量为 stuNum=64 classNum=8 ,int[8][9]

int[][] rs = new int[classNum][stuNum/classNum+1];

for(int i=0;i

int x = i%classNum;//求余 64/8 0 1 2 3 4 5 6 7 横坐标

int y = i/classNum;//整除 64/8 0 1 2 3 4 5 6 7 8 纵坐标

//求余x=0,整除y!=0的时候,type取反

if(x==0 && y!=0){ // 8-false 16-true 24-false 32-true 40-false 48-true 56-true 64-false

type=!type;

}

if(!type){

x = classNum-i%classNum-1; //班级数-序号%班级数-1

y = i/classNum;//序号/班级数

}

rs[x][y]=i+1;

/** x求余 y整除 rs数组

* i=0;x=0;y=0;type=true,rs[0][0]=1;

* i=1;x=1;y=0;type=true,rs[1][0]=2;

* i=2;x=2;y=0;type=true,rs[2][0]=3;

* i=3;x=3;y=0;type=true,rs[3][0]=4;

* i=4;x=4;y=0;type=true,rs[4][0]=5;

* i=5;x=5;y=0;type=true,rs[5][0]=6;

* i=6;x=6;y=0;type=true,rs[6][0]=7;

* i=7;x=7;y=0;type=true,rs[7][0]=8;

* i=8;x=6;y=1;type=false,rs[6][1]=9;

* i=9;x=6;y=1;type=false,rs[7][1]=10;

* i=10;x=

*/

}

return rs;

}

}

最后

以上就是雪白柜子最近收集整理的关于java 分班_新生——S型分班算法的全部内容,更多相关java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(114)

评论列表共有 0 条评论

立即
投稿
返回
顶部