源代码:
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 #define MAX 100
5 #define C 5.9
6 #define N 5
7
8 #include <iostream>
9 using namespace std;
10
11 struct stationItem{
12 int sn;
13 float cost;
14 float p;
15 };
16
17 struct queue{
18 stationItem *qe;
19 int front;
20 int tail;
21 int maxlen;
22 };
23
24 int initQueue(struct queue *q,int max)
25 {
26 if(max < 0)
27 {
28 printf("max is invalid!\n");
29 return -1;
30 }
31 q->maxlen = max;
32 q->qe = (stationItem *)malloc(max * sizeof(stationItem));
33 if(!q->qe)
34 {
35 printf("Memory alloc error!\n");
36 return -1;
37 }
38 q->front = q->tail = 0;
39 return 0;
40 }
41
42 int enQueue(struct queue *q,stationItem x)
43 {
44 if((q