摘要:
栈数组实现一:优点:入栈和出栈速度快,缺点:长度有限(有时候这也不能算是个缺点)public class Stack { private int top = -1; private Object[] objs; public Stack(int capacity) throws Exception{ if(capacity top: | "); for(int i = 0 ; i top: | 1 | 2 | 2bottom -> top: | 1 | bottom -> top: | 1 | 99 | Exception in thread "main&quo 阅读全文
摘要:
长度为N的数组升序排序一,冒泡排序public class BubbleSort { private double[] data; public BubbleSort(double[] data) { this.data = data; } public void sort(){ for(int p = data.length - 1 ; p > 0 ; p--){ for(int i = 0 ; i data[i+1] ){ double tmp = data[i]; data[i] = data[i+1]; data[i+1] = tmp; } ... 阅读全文