Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
36
Task/Priority-queue/C/priority-queue-4.c
Normal file
36
Task/Priority-queue/C/priority-queue-4.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "pairheap.h"
|
||||
|
||||
struct task {
|
||||
pq_node_t hd;
|
||||
char task[40];
|
||||
};
|
||||
|
||||
void main() {
|
||||
heap_t heap = NULL;
|
||||
struct task *new;
|
||||
|
||||
HEAP_PUSH(new, 3, &heap);
|
||||
strcpy(new->task, "Clear drains.");
|
||||
|
||||
HEAP_PUSH(new, 4, &heap);
|
||||
strcpy(new->task, "Feed cat.");
|
||||
|
||||
HEAP_PUSH(new, 5, &heap);
|
||||
strcpy(new->task, "Make tea.");
|
||||
|
||||
HEAP_PUSH(new, 1, &heap);
|
||||
strcpy(new->task, "Solve RC tasks.");
|
||||
|
||||
HEAP_PUSH(new, 2, &heap);
|
||||
strcpy(new->task, "Tax return.");
|
||||
|
||||
while (heap != NULL) {
|
||||
struct task *top = (struct task *) heap;
|
||||
printf("%s\n", top->task);
|
||||
heap = heap_pop(heap);
|
||||
free(top);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue