public class Queue {
public static void main(String[] args) {
}
}
class ade{
int Q_max=5;
int rear=-1;
int front=-1;
int [] arr=new int[Q_max];
public boolean isEm(){
return rear==front;
}
public boolean isMax(){
return rear==Q_max-1;
}
public int GetQueue(){
if(isEm()){
throw new RuntimeException("队列空,不能对其取出数据");
}
front++;
return arr[front];
}
public void InQueue(int num){
if(isMax()){
throw new RuntimeException("队列满,不能对其添加数据");
}
rear++;
arr[rear]=num;
}
}
【无标题】
最新推荐文章于 2024-09-05 10:39:00 发布