Practice #1
Lesson 9 of 12 in Coddy's Queue - Data Structures Series #2 course.
The next challenges are designed to use a queue. The Queue data structure is already provided for you — use it!
Challenge
EasyWrite a function reverse that gets an integer array as input (a) and returns the reversed array.
Use the provided Queue to solve this problem!
Try it yourself
#include <stdio.h>
#include <stdlib.h>
#include "solution.h"
int main() {
int* a = (int*)malloc(sizeof(int) * 1000);
int aSize = 0, x;
while (scanf("%d", &x) == 1) a[aSize++] = x;
int returnSize;
int* result = reverse(a, aSize, &returnSize);
for (int i = 0; i < returnSize; i++) printf("%d\n", result[i]);
free(a);
return 0;
}