链队列c语言实验报告,队列实验报告

《队列实验报告》由会员分享,可在线阅读,更多相关《队列实验报告(7页珍藏版)》请在人人文库网上搜索。

1、实验名称队列专业软件工程姓名学号实验目的实验环境实验内容、算法描述及运行结实验内容:编写一个程序实现链队列的各种基本运算,并在此基础上设计 一个主程序,完成如下功能:(1)(2)(3)(4)初始化并建立链队列入链队列出链队列遍历链队列1 掌握队列的顺序表示和实现。 2掌握队列的链式表示和实现。Visual c typedef struct node int data; struct node *n ext;JD; typedef JD * Link;Link fron t=NULL;Link rear=NULL; void addqueue(i nt value) Link newno de;。

2、newno de=(Li nk)malloc(sizeof(JD); newno de-data=value;newno de-n ext=NULL;if(rear = =NULL) front = newnode; elserear - n ext = newno de;rear = newno de;int delqueue() Link top; int temp; top=fr ont; front=front-n ext; temp=top-data; free(top);return temp; else return -1;mI *M EKl R13 ihm Tf ITL: i”。

3、i 7 * 卫qC * -nv t - Mf L丄钢 d m ,阪卄 | 沖 li tih |创* |削Ef nr 亠4 列Md,.I 刨 /Gff9flM393 运行未成功,有四个错,不知道如何修改,我知道前面应该用 标准 C 语言格式,#i nclude vstudio.h void ma in。可是加 上后错误反而变多了,望老师可以辅导一下。以下是老师给的参考程序,以及我的运行结果。00里面句式比 较复杂,还是有些不太明白#in clude#in clude#defi ne ElemType inttypedef struct Qnode ElemType data;struct Qno。

4、de *n ext;Qno detype;typedef structQno detype *front;Qno detype *rear;Lqueue;/*初始化并建立链队列*/void creat(Lqueue *q)Qno detype *h;int i,n,x;printf(输入将建立链队列元素的个数:n=);scan f(%d,&n);h=(Q no detype*)malloc(sizeof(Q no detype);h- next=NULL;q_fron t=h;q-rear=h;for(i=1;idata=x;s- next=NULL;q-rear- n ext=s;q-rea。

5、r=s;/*出链队列*/ElemType Ldelete(Lqueue *q)Qno detype *p;ElemType x;if(q- fron t=q-rear)printf(队列为空!n”);x=0;elsep=q-front_n ext;q-front-n ext=p-n ext;if(p- next=NULL)q-rear=q-front;x=p-data; free(p);return(x);/*遍历链队列*/void display(Lqueue *q)Qno detype *p;p=q-fro nt- next;/*指向第一个数据兀素节点*/printf(n链队列兀素依次为:。

6、);while(p!=NULL) prin tf(%d,p-data);p=p-n ext;printf(nn遍历链队列结束!n);mai n() Lqueue *p;int x,cord;prin tf(n*第一次操作请选择初始化并建立链队列!*n );doprintf(n链队列的基本操作n );prin tf(”=n);prin tf(主菜单n);prin tf(=n);printf(”1初始化并建立链队列n);printf(”2入链队列n);printf(”3出链队列n);printf(”4遍历链队列n);prin tf(5结束程序运行n);prin tf(=n); scan f(%d,。

7、 &cord);switch(cord) case 1: p=(Lqueue *)malloc(sizeof(Lqueue); creat(p);display(p);break;case 2: printf(请输入队列元素的值:x=);scan f(%d, &x);Lappe nd(p,x); display(p);break;case 3: printf(出链队列元素:x=%dn,Ldelete(p); display(p);break;case 4:display(p);break;case 5:exit (0);while (cord J 卜 川芒7衍鼻实验感想此次试验难度较大,运行不太顺利,望老师可以指点一下。 入队出队试验基本过程还是可以理解, 但整体嵌入C语言结构 还是不太明白,看来要恶补了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值