Skip to content

Commit

Permalink
배열로 구현한 큐
Browse files Browse the repository at this point in the history
  • Loading branch information
hyejun0608 committed Oct 21, 2020
1 parent b27ff17 commit 99c8dab
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Queue.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
int rear = -1;
int front = -1;
int addq(int* queue, int value);
int deleteq(int* queue);

int main() {
int arr[10];
for (int i = 0; i < 10; i++) addq(arr, i);
for (int i = front + 1; i < 10; i++) printf("%d ", arr[i]);
printf("\nrear: %d", rear);
return 0;
}

int addq(int* queue, int value) {
if (rear >= 9) return printf("Queue is FULL!");
else queue[++rear] = value;
}

int deleteq(int* queue) {
if (front == rear) return printf("Queue is Empty");
return queue[++front];
}

0 comments on commit 99c8dab

Please sign in to comment.