我们大一这个学期学的【软件技术基础(数据结构)】,现在期末老师要求交一份3000字左右的课程设计分析报告,内容包括:
【1】链式存储队列的数据结构(逻辑结构+存储结构)分析
【2】链式存储队列的基本C语言结构体分析与定义
【3】链式存储队列各基本操作的功能及实现分析
【4】主程序设计分析
问题4的主程序要求和主程序如下:
利用自编的子程序实现以下功能:
①创建一个空队
②判断新建的队列是否为空
③提示用户输入"队列的长度"
④根据用户输入的"队列的长度",逐一提示用户输入"队列中的各个元素", 完成队列的构造; */
⑤判断此时的队列是否为空
⑥调用子程序打印当前队列的队首元素和队尾元素
⑦编写打印队列元素的子程序PrintNode( );
⑧清空队列,连续3次做下列操作:入队4个元素,出队2个元素,打印队列, 打印当前队列的队首元素和队尾元素;
⑨要求:提供尽可能友好的人机对话界面,便于用户(非程序设计使用 者)
【主程序】
#include "stdio.h"
#include "math.h"
struct NODE_TYPE
{
int Data;
struct NODE_TYPE *pNext;
};
struct LINK_QUEUE
{
struct NODE_TYPE *front;
struct NODE_TYPE *rear;
int Length;
};
/*下面为自行建立的自编子程序文件*/
#include "lab8h.h"
main()
{
void PrintNode();
/*下面填写主程序*/
void InitQueue();
int IsEmpty();
void Add();
int Del();
int GetFront();
int GetRear();
void Clear();
void PrintNode();
int judgeEmpty;
int n;
int i;
int x;
int j;
struct LINK_QUEUE *Queue;
printf("Initiate Queue!\n");
InitQueue(Queue);
judgeEmpty=IsEmpty(Queue);
if(judgeEmpty==1)
printf("Queue Empty!\n");
else
printf("Queue is not Empty!\n");
printf("The Lengrh of Queue is:");
scanf("%d",&n);
printf("Please push datas into the Queue that you want\n");
for(i=1;i<=n;i++)
{
printf("\nEnter the %dth data:",i);
scanf("%d",&x);
Add(Queue,x);
}
judgeEmpty=IsEmpty(Queue);
if(judgeEmpty==1)
printf("Queue Empty!\n");
else
printf("Queue is not Empty!\n");
printf("Front of Queue:%d,Rear of Queue:%d\n",GetFront(Queue),GetRear(Queue));
printf("\nNow we've Cleared the Queue,you should do three times like this:Add 4 elements into the Queue ,the System will Delete 2 elements,then we will print the Queue and the Front of Queue,the Rear of Queue\n");
Clear(Queue);
for(i=1;i<=3;i++)
{
printf("\nthe %dth time:\n",i);
for(j=1;j<=4;j++)
{
printf("\tEnter the %dth data:",j);
scanf("%d",&x);
Add(Queue,x);
}
Del(Queue);
Del(Queue);
PrintNode(Queue);
printf("Front of Queue:%d,Rear of Queue:%d\n",GetFront(Queue),GetRear(Queue));
}
getch();
}
********************************************************************
【请每个问题分开回答,可以复制网上内容,但请不要随意乱复制,回答的好的我还会追加到最高(250分)】
********************************************************************
我的邮箱是[email protected]
只知道其中一个问题的也可以回答。
先谢谢大家了。