帮我修改一下程序,谢谢 - 爱问答

(爱问答)

帮我修改一下程序,谢谢

/*循环队的实现 

题目内容:

 建立顺序循环队如下:

#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不会有中文的输入、输出提示的)

若你的参考别人的程序,建议自己先试重新写下


程序不是一般人能帮你的了,只有熟悉的专业认识才可以

相关标签:谢谢

下一篇:数据结构折半查找(二分法查找)

上一篇:最近arenaofvalor很火呀,我也想玩,怎么创建账号啊?

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?