- package com.eshore.sweetop.dataframe;
- public class Quene {
- private int head=-1;
- private int tail=0;
- private int[] q;
- public Quene(){
- q=new int[100];
- }
- public Quene(int n){
- q=new int[n];
- }
- public void en(int x){
- if(head==-1){
- head=0;
- }
- q[tail]=x;
- if(tail==q.length-1){
- tail=1;
- }else{
- tail=tail+1;
- }
- }
- public int de(){
- int x=q[head];
- if(head==q.length-1){
- head=0;
- }else{
- head=head+1;
- }
- return x;
- }
- public static void main(String[] args) {
- Quene q=new Quene();
- q.en(4);
- q.en(3);
- System.out.println(q.de());
- System.out.println(q.de());
- }
- }