最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
球钟问题(栈和队列的应用)
时间:2022-07-02 10:58:29 编辑:袖梨 来源:一聚教程网
#include
#include
#include
#define N 30 /*27<=N<=127*/
#define NULL 0
typedef struct Qnode /*定义队列的接点类型*/
{
int data;
struct Qnode *next;
}Qnode,*Queueptr;
Queueptr p,q;
typedef struct
{
Queueptr front;
Queueptr rear;
}linkQueue;
linkQueue *Q; /*定义队列*/
typedef struct stack4 /*定义分钟栈*/
{
Queueptr top;
Queueptr base;
}stack4;
stack4 *min;
typedef struct stack11 /*定义5分钟栈类型(小时栈类型)*/
{
Queueptr top;
Queueptr base;
}stack11;
stack11 *fmin,*hour; /*建立五分钟和小时栈*/
int minute;
void initQueue(linkQueue *O) /*队列的初始化*/
{
int i=1,j;
Queueptr head,new;
head=(Qnode *)malloc(sizeof(Qnode));
if(!head)
{
printf("failture for applying a area!n");
exit(0);
}
O->front=p=head;
head->data=i;
head->next=NULL;
while(i{
new=(Qnode *)malloc(sizeof(Qnode));
if(!new)
{
printf("failture for applying a area!n");
exit(0);
}
head->next=new;
head=head->next;
head->data=++i;
}
head->next=NULL;
O->rear=head;
}
相关文章
- 羊蹄山之魂诱敌狼袭成就如何完成 09-02
- TPLink TLWDR5780 无线路由器修改无线名称及密码操作流程 09-02
- 歧路旅人0全职业角色有什么特点 09-02
- 胜利女神寂叶部队最强角色是什么 09-02
- 明末渊虚之羽单手剑双刀长枪轮椅如何打法加点 09-02
- 《盖瑞模组》攻略 简评 配置 下载 09-02