Created
October 10, 2017 17:39
-
-
Save tlively/9c2f1c93cfd6a278bff4112073b53b45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define N_ITEMS 10 | |
/* Uncomment this section to use linked lists | |
typedef struct node | |
{ | |
int val; | |
struct node *next; | |
} | |
// the linked list | |
node *head; | |
node *tail; | |
*/ | |
/* Uncomment this section to use an array | |
#define ARRAY_LENGTH 20 | |
int array[ARRAY_LENGTH] = {}; | |
*/ | |
// adds a value to the queue. Returns true if successful, otherwise false. | |
bool enqueue(int val) | |
{ | |
(void)val; | |
return false; | |
} | |
// gets a value off the queue and returns it. | |
// The queue must contain at least one item. | |
int dequeue(void) | |
{ | |
return -1; | |
} | |
int main(void) | |
{ | |
// enqueue numbers 1-10 | |
for (int i = 0; i < N_ITEMS; i++) | |
{ | |
if (!enqueue(i)) | |
{ | |
printf("Could not enqueue %d\n", i); | |
return 1; | |
} | |
} | |
// dequeue the numbers and print them | |
for (int i = 0; i < N_ITEMS; i++) | |
{ | |
printf("%d\n", dequeue()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment