test1.c

#include "linkQueue.h"

void visit(QElemType e)
{
    printf("%d\n", e);
}


int main()
{
    LinkQueue q;
    InitQueue(&q);
    puts("隊列是否爲空");
    printf("%s\n", QueueEmpty(q) ? "is empty" : "is not empty");
    puts("當前隊列長度");
    printf("%d\n", QueueLength(q));

    printf("Please input 6 elements:\n");
    int i,e;
    for(i = 0; i < 6; i++)
    {
        scanf("%d", &e);
        EnQueue(&q, e);
        puts("當前隊列長度");
        printf("%d\n", QueueLength(q));
    }

    QueueTraverse(q, visit);

    puts("刪除元素");
    for(i = 0; i < 2; i++)
    {
        DeQueue(&q, &e);
        puts("刪除元素的值爲:\n");
        printf("%d\n", e);
    }

    puts("當前隊列長度");
    printf("%d\n", QueueLength(q));

    puts("當前棧頂:");
    GetHead(q, &e);
    printf("%d\n", e);

    puts("請空隊列中");
    ClearQueue(&q);

    puts("當前隊列長度");
    printf("%d\n", QueueLength(q));

    puts("當前棧頂:");
    GetHead(q, &e);
    printf("%d\n", e);

    puts("隊列是否爲空");
    printf("%s\n", QueueEmpty(q) ? "is empty" : "is not empty");

    puts("銷燬隊列中");
    DestroyQueue(&q);
    return 0;
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章