练习 #1
Coddy 队列:数据结构系列 #2 课程的第 9 课,共 12 课。
接下来的挑战需要使用队列。已经为你提供了 Queue 数据结构,快来使用它吧!
挑战
简单编写一个函数 reverse,它接收一个整数数组作为输入(a),并返回反转后的数组。
使用提供的队列来解决这个问题!
亲手试试
#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;
}
队列:数据结构系列 #2中的所有课
自己练习: C 在线编译器