# 在1d数组中填充2d数组

``````wwwwwwwwwwwwwww
wffbbbbbbbbbffw
wf1bwbwbwbwbwfw
wbbbbbbbbbbbbbw
wbwbwbwbwbwbwbw
wbbbbbbbbbbbbbw
wbwbwbwbwbwbwbw
wbbbbbbbbbbbbbw
wbwbwbwbwbwbwbw
wbbbbbbbbbbbbbw
wbwbwbwbwbwbwbw
wbbbbbbbbbbbbbw
``````

``````fffffffffffffff
wffffffffffffff
fwfffffffffffff
fffffffffffffff
fffffffffffffff
fffffffffffffff
ff1ffffwfffffff
fffffffwfffffff
fffffffwfffffff
fffffffwfffffff
fffffffffffffff
fff2fffffffffff
fffffffffffffff
fffffffffffffff
fffffffffffffff
wffffffffffffff
fwfffffffffffff
fffffffffffffff
fffffffffffffff
fffffffffffffff
fffffffwfffffff
fffffffwfffffff
fffffffwfffffff
fffffffwfffffff
fffffffffffffff
fffffffffffffff
fffffffffffffff
fffffffffffffff
fffffffffffffff
``````

``````void            Map::get_size_map(char *dat_name)
{
std::ifstream ifs;
int x;
int y;
char c;

x = 0;
y = 0;
c = 0;
ifs.open (dat_name, std::ifstream::in);
if(ifs.is_open())
{
while(!ifs.eof())
{
c = ifs.get();
if(y == 0 && c != '\n')
x++;
if(c == '\n')
y++;
}
}
ifs.close();
this->x_map = x;
this->y_map = y;
}
``````

``````int Map::fix_Pos(int x, int y)
{
int x_r;
int y_r;

x_r = x * this->x_map;
return (x_r + y);
}
``````

``````int Map::fix_Pos(int x, int y)
{
int x_r;
int y_r;

x_r = x * this->x_map;
return (x_r + y);
}
``````

``````int Map::fix_Pos(int x, int y)
{
return (y * this->x_map + x);
}
``````

0条评论