level 7
ryhehuhhgh
楼主
本来是想将数组初始化为 中间是0,边界是1,然而结果不可描述,见图片
源码如下
#include <iostream>
using namespace std;
const int width = 14;
const int hight = 10;
class WindoW{
public:
WindoW();
private:
void print()
{
for (int i=0;i<hight+2;++i)
{
for (int j=0;j<width+2;++j)
cout<<map[i][j]<<" ";
cout<<endl;
}
}
int map[width+2][hight+2];
};
WindoW::WindoW()
{
for (int i=1;i<width+1;++i)
map[0][i]=map[hight+1][i]=1;
for (int i=0;i<hight+2;++i)
map[i][0]=map[i][width+1]=1;
for (int i=1;i<hight+1;++i)
for (int j=1;j<width+1;++j)
map[i][j]=0;
print();
}
int main()
{
WindoW win;
return 0;

2018年08月14日 07点08分
1
源码如下
#include <iostream>
using namespace std;
const int width = 14;
const int hight = 10;
class WindoW{
public:
WindoW();
private:
void print()
{
for (int i=0;i<hight+2;++i)
{
for (int j=0;j<width+2;++j)
cout<<map[i][j]<<" ";
cout<<endl;
}
}
int map[width+2][hight+2];
};
WindoW::WindoW()
{
for (int i=1;i<width+1;++i)
map[0][i]=map[hight+1][i]=1;
for (int i=0;i<hight+2;++i)
map[i][0]=map[i][width+1]=1;
for (int i=1;i<hight+1;++i)
for (int j=1;j<width+1;++j)
map[i][j]=0;
print();
}
int main()
{
WindoW win;
return 0;

