队列排序,先进先出


  /**
     * 队列是一种特殊的线性结构,它只允许在队列的首部(head)进行删除操作,这称为“出队”,而在队列
     * 的尾部(tail)进行插入操作,这称为“入队”。当队列中没有元素时(即head==tail),称为 空队列,
     * “先进先出”(FirstIn First Out,FIFO)原则
     */
    public static void main(String[] args)
    {
        int aa[] = new int[100];
        
        int a[] = {0, 6, 3, 1, 7, 5, 8, 9, 2, 4}, head = 1, tail = 10;
        
        for (int b = 0; b < a.length; b++)
        {
            aa[b] = a[b];
        }
        
        while (head < tail)
        {
            System.out.print(aa[head] + " ");
            head++;
            aa[tail] = aa[head];
            tail++;
            head++;
        }
    }

先将代码贴出来,记录一下小案例


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM