最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
球钟问题(栈和队列的应用)
时间:2008-04-26 编辑:简简单单 来源:一聚教程网
#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;
}
-
上一个: 面向实践的程序设计--一个医药管理系统
-
下一个: 结 构(struct)
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10