最新下载
热门教程
- 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;
}
相关文章
- 波场 05-02
- 狗狗币能涨到5万美刀吗 05-02
- 游戏dau下降 05-02
- btc行情 05-02
- 从零开始学虚拟货币交易 05-02
- 比特币实时交易策略 05-02