1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
int MapDisplay (int *temparray1,int length, int *MapArray, int NumCols)
{
int **UnitInfoArrayCpy;
UnitInfoArrayCpy = &temparray1;
for (int m; m< length; m++)
{std::cout<<UnitInfoArrayCpy[m]<<" O \n";};
int temp1;
int temp2;
int temp3;
for (int i = 0; i <= length; i+ 5)
{
if (UnitInfoArrayCpy[i+2] != 0)
{
temp1 = *UnitInfoArrayCpy[i];
temp2 = *UnitInfoArrayCpy[i+1];
temp3 = MapArray[temp1 * NumCols + temp2];
temp3 = temp3 + (*UnitInfoArrayCpy[i+3] * 10);
MapArray[temp1 * NumCols + temp2] = temp3;
};
};
std::cout<<"Map:"<<"\n \n";
for (int nRow = 0; nRow < nNumRows; nRow++)
{
for (int nCol = 0; nCol < nNumCols; nCol++)
{
//This part would contain a very long cout, so I'll omit it to save space
};
std::cout <<"\n" << "\n";
};
}
int main ()
{
const int nNumRows = 5;
const int nNumCols = 7;
int MapArray[nNumRows][nNumCols] =
{
{ 3, 3, 1, 2, 5, 5, 1, },
{ 3, 6, 6, 2, 5, 1, 1, },
{ 2, 2, 2, 2, 2, 2, 2, },
{ 4, 1, 1, 1, 3, 3, 3, },
{ 4, 4, 1, 1, 3, 3, 4, }
};
int UnitInfoArray[] = {1,1,10,1,1,1,3,10,2,2};
int lengthUnitInfo = sizeof(UnitInfoArray)/sizeof(int);
MapDisplay (UnitInfoArray, lengthUnitInfo, MapArray, nNumCols);
}
|