struct element int value int index int mass_index struct queue struct

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
struct element {
int value;
int index;
int mass_index;
};
struct queue {
struct element *data;
int cap;
int qcount;
};
void initelem (struct queue *turn, int n, int b)
{
int i;
for (i = 0; i < n; i++) {
turn->data[i].index = b;
turn->data[i].mass_index = i;
}
}
void initqueue (struct queue *turn, int size, int val)
{
turn->data = (struct element*)malloc(size * sizeof(struct element));
turn->cap = size;
turn->qcount = size;
initelem (turn(или &turn), size, val);
}