嘿伙计们,我想在 c 中连接多个 2d 数组,这在我只做两个时会发生什么,但如果我做的更多,它的总和在一起。似乎每个周期它都会增加一个:
数组 1
222222222222222222222
000000000001000000000
000000000001000000000
000000000001000000000
000000000001000000000
111111111111111111111
数组 2
222222222222222222222
000000000001000000000
000000000001000000000
000000000000000000000
000000000001000000000
111111111111111111111
我想要的是
222222222222222222222222222222222222222222
000000000001000000000000000000001000000000
000000000001000000000000000000001000000000
000000000001000000000000000000000000000000
000000000001000000000000000000001000000000
111111111111111111111111111111111111111111
我得到了什么
222222222222222222222000000000001000000000
000000000001000000000000000000001000000000
000000000001000000000000000000000000000000
000000000001000000000000000000001000000000
000000000001000000000000111111111111111111
111111111111111111111111111111111111111111
连接函数
#define map_height 6
#define map_length 21
#define map_stage_length 5
char ** concatenate(){
char **array=create2DCharArray(map_height,map_length*map_stage_length);
char **mapsarray[5]={create2DCharArray(map_height,map_length),
create2DCharArray(map_height,map_length),
create2DCharArray(map_height,map_length),
create2DCharArray(map_height,map_length),
create2DCharArray(map_height,map_length)};
int i=0,j=0,n=0;
mapsarray[0]=load_map("./resources/maps/map1.map");
mapsarray[1]=load_map("./resources/maps/map2.map");
mapsarray[2]=load_map("./resources/maps/map2.map");
mapsarray[3]=load_map("./resources/maps/map2.map");
mapsarray[4]=load_map("./resources/maps/map2.map");
for (i = 0; i < map_height; i++)
{
for (n = 0; n < map_stage_length; n++)
{
for (j = 0; j < map_length; j++)
{
array[i][(n*map_length)+j]=mapsarray[n][i][j];
}
}
}
return array;
}
你知道为什么它会向上推吗?