作业帮 > 综合 > 作业

编写一个算法,将一个环形列队(容量为n,元素下标从1到n)的元素倒置.应该要用到栈和队列,

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/10/01 12:24:26
编写一个算法,将一个环形列队(容量为n,元素下标从1到n)的元素倒置.应该要用到栈和队列,
编写一个算法,将一个环形列队(容量为n,元素下标从1到n)的元素倒置.应该要用到栈和队列,
实现逆转的函数为void ReverseQueue(),其他的都是辅助测试所用.
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "math.h"
#define MAX 10
struct Queue
{
int front;
int rear;
int a[MAX];
}Que;
void Initial();
int InsertQueue(int n);
int DeleQueue();
void ReverseQueue();
void PrintQ();
//该函数是为了测试逆转函数的正确性
void TestFun();
int main()
{

Initial();
TestFun();
return 0;
}
void Initial()
{
Que.front=0;
Que.rear=0;
for (int i=0; i