示例#1
0
int main(int argc, char *argv[])
{
    pq_init(5);
    assert(pq_empty());

    pq_insert(1);
    pq_insert(2);
    pq_insert(3);
    pq_insert(4);
    pq_insert(5);
    pq_show(); nl();

    int i;
    for (i = 0; i < 5; i++)
    {
        pq_delmax();
        pq_show(); nl();
    }

    return 0;
}
示例#2
0
int main(void)
{
    int n = 5;
    pq_t pq = pq_init(n);
    int i;

    for (i = 0; i < n; i++) {
        int item = rand() % 100;
        printf("%3d ", item);
        pq_insert(pq, item);
    }

    putchar('\n');

    /*pq_print(pq);*/
    while (!pq_empty(pq)) {
        printf("%3d ", pq_delmax(pq));
    }

    putchar('\n');
    pq_finalize(&pq);
    return 0;
}