#include<stdio.h>
#include<stdlib.h>
#define MaxSize 5
#define MaxWindow 5
#define MaxProc 1
typedef struct{
int T;
int P;
}People;
typedef struct{
People data[MaxSize];
int front, rear;
}SqQueue;
void InitQueue(SqQueue *&q){
q = (SqQueue *)malloc(sizeof(SqQueue));
q->front = q->rear = 0;
}
void Destroy(SqQueue *&q){
free (q);
}
bool QueueEmpty(SqQueue *q){
return(q->front == q->rear);
}
bool enQueue(SqQueue *&q, People e){
if ((q->rear + 1) % MaxSize == q->front)
return false;
q->rear = (q->rear + 1) % MaxSize;
q->data[q->rear] = e;
return true;
}
bool deQueue(SqQueue *&q, People &e){
if (q->front == q->rear)
return false;
q->front = (q->front + 1) % MaxSize;
e = q->data[q->front];
return true;
}
double QueueingAtBank(SqQueue *&Q, int N){
struct People Next;
int K;
int TotalTime;
int CurrentTime;
int Window[MaxWindow];
int WaitTime;
int WinAvail;
int i, j;
scanf("%d", &K);
if (N < K)return 0;
for (i = 0; i < K; i++)
Window[i] = 0;
TotalTime = 0;
while (!QueueEmpty(Q)){
WinAvail = FindNextWindow(Window, K ,&WaitTime);
CurrentTime += WaitTime;
People X;
Next = deQueue(Q,X);
if (CurrentTime >= Next.T)
TotalTime += (CurrentTime - Next.T);
else
{
WaitTime = Next.T - CurrentTime;
for (j = 0; j < K; j++)
{
Window[j] -= WaitTime;
if (Window[j] < 0)
Window[j] = 0;
}
CurrentTime = Next.T;
}
Window[WinAvail] = Next.P;
}
return((double)TotalTime / (double)N);
}
int FindNextWindow(int W[], int k, int *WaitTime)
{
int WinAvail;
int MinW = MaxProc + 1;
int i;
for (i = 0; i < k; i++)
if (W[i] < MinW)
{
MinW = W[i];
WinAvail = i;
}
*WaitTime = MinW;
for (i = 0; i < k; i++)
W[i] -= MinW;
return WinAvail;
}
int main(){
int N;
SqQueue *Q;
int i;
People X;
int N= MaxSize;
for (i = 0; i < N; i++){
scanf("%d %d", &X.T, &X.P);
enQueue(Q, X);
}
printf("Average waiting time=%.if.\n", QueueingAtBank(Q, N));
Destroy(Q);
return 0;
}
请问各位大佬我想用People Next中的Next以及后面的所有Next报错
我想用来表示下一位顾客
但是不知道该怎么表示