帮我修改一下程序,谢谢
/*循环队的实现
题目内容:
建立顺序循环队如下:
#define Maxs 10
typedef int EType;
typedef struct
{
EType elem[Maxs];
int front,rear;
}
实现如下操作:
1.进队2次;
2.出队1次;
3.进队3次;
4.全部出队
输入描述
输入进队的数据;
输出描述
分2行输出出队的数据;
输入样例
1 2 3 4 5
输出样例
1
2 3 4 5*/
#include<stdio.h>
#include<stdlib.h>
#define OVERFLOW -2
#define MAXQSIZE 10
typedef struct {
int *base;
int front;
int rear;
}Sqqueue;
int InitQueue(Sqqueue &Q) {
Q.base = (int * )malloc(MAXQSIZE*sizeof(int));
if (!Q. base) exit (OVERFLOW);
Q.front=Q.rear =0;
return 1;
}
int EnQueue(SqQueue &Q) {
int e;
if ((Q. rear+ 1) % MAXQSIZE == Q. front)
{
printf("队列已满,不能进队 ");
return -1;
}
printf("请输入进队元素:");
scanf("%d",&e);
Q.base[Q.rear] = e;
Q.rear = (Q. rear + 1) % MAXQSIZE;
return 1;
}
int DeQueue (SqQueue &Q) {
int e;
if (Q. front == Q. rear)
{
printf("队列已经为空 ");
return -1;
}
e = Q. base[Q. front];
printf("%d出队 ",e);
Q.front = (Q.front + 1) % MAXQSIZE;
return 1;
}
int main()
{
int k;
SqQueue Q;
InitQueue(Q);
EnQueue(Q);
EnQueue(Q);
DeQueue(Q);
EnQueue(Q);
EnQueue(Q);
EnQueue(Q);
DeQueue(Q);
return 0;
}
你的程序与你的要求没有关系啊
你连基本的数据结构都与要求不一致
且输入、输出也不正确(一般OJ不会有中文的输入、输出提示的)
若你的参考别人的程序,建议自己先试重新写下
程序不是一般人能帮你的了,只有熟悉的专业认识才可以