【发布时间】:2014-10-11 02:39:06
【问题描述】:
我正在尝试在地图/网格上放置作物。裁剪是需要在地图边框中显示的字符串。我需要使用二维数组来显示将在地图上形成裁剪形状的各个字符。这是我到目前为止的代码,但是当它们显示时,它并没有给我正确的裁剪形状。
bool Crop::place(char map[MAPL][MAPW],int x_crop,int y_crop)const{
cout << '\n';
cout << setw(24) << right << "11111111112\n";
cout << setw(24) << right << "12345678901234567890\n";
cout << " " << setw(21) << setfill('-') << left << '+' << right << '+' << setfill (' ') << endl;
for(int x=0; x < MAPW;x++){
cout << setw(2) << right << x+1 << "|";
for(int y=0; y < MAPL;y++){
cout << map[x][y];
}
cout << "|" << endl;
}
cout << " " << setw(21) << setfill('-') << left << '+' << right << '+' << setfill (' ') << endl;
cout << setw(24) << right << "11111111112\n";
cout << setw(24) << right << "12345678901234567890\n";
return true;
}
这里是输出应该是什么样子的示例。它有两种作物,“c”和“p”在地图上是 20 宽 x 10 高
11111111112
12345678901234567890
+--------------------+
1| |
2| |
3| cc |
4| cc |
5| cc |
6| cc |
7| pppppppp |
8| pppppppp |
9| pppppppp |
10| |
+--------------------+
11111111112
12345678901234567890
【问题讨论】:
标签: c++ map grid char multidimensional-array