index block space
0 0 1
1 0 1
2 0 1
3 0 1
4 0 1
5 1 0
6 1 0
7 1 0
8 1 0
9 1 0
10 2 0
11 2 0
12 2 0
13 2 0
14 2 0
15 3 0
16 3 0
17 3 0
18 3 0
19 3 0
20 4 0
21 4 0
22 4 0
23 4 0
24 4 0
我使用for循环从结构中打印出上面的表格。我有一组可用的块{2,4}和一个包含6个项目{6,7,8,9,10,11}的数组。如何打印表格,使得块的空间将指示空间最后一项的下一个块。已经尝试了一段时间,会感激一些帮助!谢谢!
availblock = {2,4} itemsarr = {6,7,8,9,10,11}
index block space
0 0 1
1 0 1
2 0 1
3 0 1
4 0 1
5 1 0
6 1 0
7 1 0
8 1 0
9 1 0
10 2 6
11 2 7
12 2 8
13 2 9
14 2 4
15 3 0
16 3 0
17 3 0
18 3 0
19 3 0
20 4 10
21 4 11
22 4 0
23 4 0
24 4 0
index = 0
for (int i = 0; i < availblocklen; i++) {
for (int j = 0; j < 5; j++) {
int currentblock = availblocklen[index];
int availblkindex = (5 * currentblock) + j;
for (int k = 0; k < (5 * availblock); k++) {
freeindexarr[k] == availblkindex;
}
for (int x = 0; x < itemsarr; x++) {
for (int k = 0; k < 65; k++) {
if (struct.index == availblkindex) {
if ((k + 1) % 5 == 0) {
struct.index[k].space= availblk[index+1];
}
else {
struct[k].space = itemsarr[x];
}
}
}
}
}
index++
}