模拟银行客户逗留平均时间
数据结构(C语言版)中栈的习题
#include<stdlib.h>
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
#define ERROR 0
#define OK 1
typedef struct{
int OccurTime;
int NType;
}Event;
typedef struct{
int ArrivalTime;
int Duration;
}QElemType;
struct LNODE
{
Event data;
struct LNODE *next;
};
typedef struct LNODE LNode;
typedef struct LNODE *LinkList;
typedef struct LNODE *EvenList;
typedef struct QNode{
QElemType elem;
struct QNode *next;
}QNode,*QueuePtr;
typedef struct
{ QueuePtr front;
QueuePtr rear;
}LinkQueue;
EvenList ev;
Event en;
LinkQueue q[5];
QElemType customer;
int TotalTime,CustomerNum,CloseTime;
int InitList(EvenList *L)
{
*L=(LNode *)malloc(sizeof(LNode));
if(!(*L)) exit(ERROR);
(*L)->next=NULL;
return OK;
}
int DelFirst(EvenList *L,Event *e)
{ LNode *pc,*q;
pc=*L;q=pc->next;
pc->next=q->next;*e=q->data;return OK;}
int ListEmpty(LNode L)
{LNode *p;<BR> int j=0;<BR> p=L.next;<BR> while(p)<BR> {j ;break;}
if(j==0) return 1;
else return 0;
}
int compare(Event a,Event b)
{ if(a.OccurTime>b.OccurTime) return 1;
else if(a.OccurTime==b.OccurTime) return 0;
else return -1;
}
int OrderInsert(EvenList *L,Event e,int (* cmp)(Event ,Event ))
{ LNode *p,*pc;/*把事件插入链表*/
p=(LNode *)malloc(sizeof(LNode));/*分配空间*/
if(!p) { printf("not"); return(0);}
if(ListEmpty(**L))
{ p->data=e;p->next=(*L)->next;(*L)->next=p;}
else {
switch(cmp(((*L)->next)->data,e))
{case -1:pc=(*L)->next;<BR> while(pc->next!=NULL)<BR> {<BR> if((pc->next)->data.OccurTime<=e.OccurTime)<BR> pc=pc->next;<BR> else break;<BR> }
p->data=e;p->next=pc->next;/*把它接在比它大的前*/
pc->next=p;break;
&nbs
您可能感兴趣的文章:
模拟银行客户逗留平均时间
photoshop工业级电影调色让相机照片秒变银幕大片效果教程
页面停留时间与网站停留时间详解
工商银行信用卡积分如何兑换 信用卡积分兑换规则有哪些?
linux 查看磁盘IO状态的方法
LVS调度算法和三种工作模式
django如何解决高并发
vsftp 虚拟用户高级设置
农业银行信用卡额度怎么提升 信用卡额度提升方法
phper优化MySQL千万级大表的方法详解