亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
  • MyQueue.h


    查看全部
  • 每次插入之前需要判斷一下,隊列是否已滿

    插入一個元素后,隊尾指向下一個位置,直到環形隊列已滿

    取出元素,從隊頭開始取,取出一個元素,隊頭就指向下一個元素

    隊列中空出的位置,隊列為又可以插入新的元素

    查看全部
  • 集合。關系
    查看全部
    1 采集 收起 來源:課程簡介

    2019-03-23

  • 隊列的實現,C與C++有什么區別?


    查看全部
  • 隊列分類。。。

    查看全部
    0 采集 收起 來源:隊列

    2019-03-22

  • 隊列 先入先出

    普通隊列????環形隊列


    查看全部
    0 采集 收起 來源:隊列

    2019-03-21

  • 當在堆中實例化對象時,對象當中需要有默認的構造函數(參數有默認值)

    查看全部
  • 出隊列必須用引用。別忘了數組位置取余

    查看全部
  • 環形隊列示意圖,彌補普通隊列的缺點,可充分利用每個內存空間

    查看全部
    1 采集 收起 來源:隊列

    2019-03-01

  • 普通隊列缺點

    查看全部
    0 采集 收起 來源:隊列

    2019-03-01

  • 隊列可分為

    查看全部
    0 采集 收起 來源:隊列

    2019-03-01

  • 隊列是先入先出的? ?

    查看全部
    0 采集 收起 來源:隊列

    2019-03-01

  • 數據結構是指相互之間存在一種貨多種特定關系的數據元素的集合

    查看全部
    0 采集 收起 來源:課程簡介

    2019-03-01

  • 隊列:FIFO 先入先出
    查看全部
    0 采集 收起 來源:隊列

    2019-02-21

  • #ifndef MYQUEUE_H
    #define MYQUEUE_H
    class MyQueue
    {
    public:
    ?MyQueue(int queueCapacity);
    ?virtual ~MyQueue();
    ?void ClearQueue();//清空
    ?bool QueueEmpty() const;
    ?bool QueueFull()const;
    ?int QueueLength()const;
    ?bool EnQueue(int element);
    ?bool DeQueue(int &element);
    ?void QueueTraverse();//遍歷
    private:
    ?int *m_pQueue;//隊列數組指針
    ?int m_iQueueLen;//隊列元素個數
    ?int m_iQueueCapacity;//隊列數組容量
    ?int m_iHead;
    ?int m_iTail;
    };


    #endif



    MyQueue::MyQueue(int queueCapacity)
    {
    ?m_iQueueCapacity = queueCapacity;
    ?m_pQueue = new int[m_iQueueCapacity];
    ?ClearQueue();
    }
    MyQueue::~MyQueue()
    {
    ?delete[]m_pQueue;
    ?m_pQueue = NULL;


    }
    void MyQueue::ClearQueue()
    {
    ?m_iHead = 0;
    ?m_iTail = 0;
    ?m_iQueueLen = 0;


    }
    bool MyQueue::QueueFull() const
    {
    ?if (m_iQueueLen == m_iQueueCapacity)
    ?{
    ??return true;
    ?}
    ?else
    ?{
    ??return false;
    ?}
    }
    bool MyQueue::QueueEmpty() const
    {
    ?if (m_iQueueLen == 0)
    ?{
    ??return true;
    ?}
    ?else
    ?{
    ??return false;
    ?}
    }
    int MyQueue::QueueLength()const
    {
    ?return m_iQueueLen;
    }


    bool MyQueue::EnQueue(int element)
    {
    ?if (QueueFull())
    ?{
    ??return false;
    ?}
    ?else
    ?{
    ??m_pQueue[m_iTail] = element;
    ??m_iTail++;
    ??m_iTail = m_iTail%m_iQueueCapacity;
    ??m_iQueueLen++;
    ??return true;
    ?}
    }
    bool MyQueue::DeQueue(int &element)
    {
    ?if (QueueEmpty())
    ?{
    ??return false;
    ?}
    ?else
    ?{
    ??element = m_pQueue[m_iHead];
    ??m_iHead++;
    ??m_iHead %= m_iQueueCapacity;
    ??m_iQueueLen--;
    ??return true;
    ?}
    }
    void MyQueue::QueueTraverse()
    {
    ?for (int i = m_iHead; i < m_iQueueLen+ m_iHead; i++)
    ?{
    ??cout << m_pQueue[i%m_iQueueCapacity]<<endl;
    ?}
    }


    int main()
    {
    ?MyQueue *p = new MyQueue(20);


    ?p->EnQueue(10);
    ?p->EnQueue(12);
    ?p->EnQueue(14);
    ?p->EnQueue(16);
    ?p->EnQueue(18);


    ?p->QueueTraverse();
    ?cout << endl;


    ?int e = 0;
    ?p->DeQueue(e);
    ?cout << e <<endl;


    ?p->DeQueue(e);
    ?cout << e <<endl;
    ?cout << endl;



    ?p->QueueTraverse();
    ?p->ClearQueue();
    ?cout <<endl;
    ?p->EnQueue(20);
    ?p->EnQueue(30);
    ?p->QueueTraverse();



    ?delete p;
    ?p = NULL;


    ?system("pause");
    ??? return 0;
    }


    查看全部

舉報

0/150
提交
取消
課程須知
本課程是程序世界中的核心課程 由于本門課程是以C++為編碼實現的,所以需要大家熟練掌握C++語言基礎語法。
老師告訴你能學到什么?
1、什么是數據結構、什么是隊列以及隊列的實現原理 2、如何設計隊列的類,如何完善類的設計 3、如何實現隊列的相關函數 4、如何檢驗代碼的正確性,如何完善代碼 5、如何與實際相結合,利用數據結構解決實際問題

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!