0
我需要將2d數組顯示爲地圖。 g_length和w_width是從x和y點開始的多長時間。需要創建一個需要放置在map.x_crop上的裁剪的寬度和長度的循環,而y_crop是裁剪應該創建的x和y座標。 w_width是寬度,g_length是位於類中的作物的長度或高度。將2d數組顯示爲地圖
bool Crop::place(char map[MAPL][MAPW],int x_crop,int y_crop)const{
int y_total =y_crop;
y_total = y_crop + g_length;
for(int x=0; x < MAPW;x++){
if(x==x_crop){
for(int b=0; b < w_width;b++){
if(y_total==y_crop){
map[x][y_crop] = PlantType.symbol();
x++;
y_crop++;
}else{
b=w_width;
}
x++;
}
}
}
cout << '\n';
cout << setw(24) << right << "11111111112\n";
cout << setw(24) << right << "123456789\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 << "123456789\n";
return true;}
OUT輸出繼承人應該如何看起來像:
11111111112
123456789
+--------------------+
1| |
2| |
3| cc |
4| cc |
5| cc |
6| cc |
7| pppppppp |
8| pppppppp |
9| pppppppp |
10| |
+--------------------+
11111111112
123456789
>
這是什麼問題? – Jarod42 2014-10-11 02:00:10
@ Jarod42 for循環應該如何獲得問題中提供的輸出? – Sobasofly 2014-10-11 02:07:46