摘要:
栈数组实现一:优点:入栈和出栈速度快,缺点:长度有限(有时候这也不能算是个缺点)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 阅读全文
posted @ 2014-03-30 20:25
心意合一
阅读(159)
评论(0)
推荐(0)
摘要:
长度为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; } ... 阅读全文
posted @ 2014-03-30 11:50
心意合一
阅读(206)
评论(0)
推荐(0)
浙公网安备 33010602011771号