欢迎使用CSDN-markdown编辑器
2017-10-15 18:57
211 查看
package Text;
public class Stack {
private Object[] objects;
private int head;
private int size;
}
package Text;
public class Queue {
private Object[] objects;
private int size;
private int head;
private int end;
// return null;
throw new Exception(“Queue is empty!”);
if (head == objects.length)
this.head = 0;
size–;
return objects[head++];
}
}
冒泡排序
package sort;
public class Bubble1 {
public static int[] sort(int[] a){
for(int i=0;i
public class Stack {
private Object[] objects;
private int head;
private int size;
public Stack(int size) { objects = new Object[size]; this.head = 0; this.size = 0; } public void push(Object object) throws Exception { if (this.size == objects.length) throw new Exception("this stack is full"); objects[head++] = object; size++; } public Object pop() throws Exception { if (size == 0) throw new Exception("this stack is empty"); size--; return objects[--head]; }
}
package Text;
public class Queue {
private Object[] objects;
private int size;
private int head;
private int end;
public Queue(int size) { this.objects = new Object[size]; this.head = 0; this.end = 0; this.size = 0; } public void push(Object object) throws Exception { if (this.size > objects.length) throw new Exception("Queue is full!"); objects[end++] = object; size++; } public Object pop() throws Exception { if (this.size == 0)
// return null;
throw new Exception(“Queue is empty!”);
if (head == objects.length)
this.head = 0;
size–;
return objects[head++];
}
public Object peek() throws Exception { if (this.size == 0) throw new Exception("Queue is empty!"); return objects[head]; } public boolean isEmpty() { return size == 0; } public boolean isFull() { return size == objects.length; } public int getSize() { return size; }
}
冒泡排序
package sort;
public class Bubble1 {
public static int[] sort(int[] a){
for(int i=0;i
相关文章推荐
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器
- 欢迎使用CSDN-markdown编辑器