- 4
- 0
- 约小于1千字
- 约 6页
- 2023-08-21 发布于浙江
- 举报
排序算法测试
1冒泡排序源程序
package abc;
public class Sort {
public void bubblesort(int[] a) {
int temp;
for (int i = 0; i a.length-1; i++) {
for (int j = a.length- 1; j i ; j--) {
if (a[j] a[j - 1]) {
temp = a[j];
a[j] = a[j - 1];
a[j - 1] = temp;
}
}
}
}
}
2测试程序
package abc;
import junit.framework.TestCase;
public class SortTest extends TestCase {
protected void setUp() throws Exception {
super.setUp();
}
protected void tearDown() throws Exception {
super.tearDown();
}
Sort q=new Sort();
public void testSort(){
int []a1={0};//数组为零
int []b1={0};
q.bubblesort(a1);
for(int i=0;ib1.length;i++){
assertEqu
原创力文档

文档评论(0)