使用java来实现在智能组卷中的遗传算法(急急急)
发布网友
发布时间:2022-04-23 14:05
我来回答
共1个回答
热心网友
时间:2023-09-11 02:57
题目好像是让你做个增强版的List ,简单的都实现了 程序架子大概是这样,排序查找什么的百度搜下 算法很多,套着每样写个方法就行了,测试就在main‘方法里写
public class MyList {
private String[] arr;
private int count ;
public MyList (int count){
arr = new String[count];
this.count = count;
}
public MyList (int[] intArr){
arr = new String[intArr.length];
this.count = intArr.length;
for(int i=0;i<intArr.length;i++){
arr[i] = intArr[i]+"";
}
}
public MyList (String[] stringArr){
arr = stringArr;
this.count = stringArr.length;
}
public int getLength(){
return count;
}
//清空容器内的数组。
public void clearAll(){
arr = new String[count];
}
//通过给定元素下标来删除某一元素
public void removeBySeqn(int seqn){
if(seqn >= 0 && seqn<count){
arr[seqn] = null;
}
}
public static void main(String[] args){
MyList list = new MyList (40);
MyList list1 = new MyList ({3,2,125,56,123});
MyList list2 = new MyList ({"123",""ad});
list2.removeBySeqn(0);
list1.clearAll();
}
}