プログラムは、すべての外側の線が 0 を出力し、内側の線が 1 を出力する 12x24 のグリッドを出力することになっています。
これは、最初の列と行を0に出力するために試したものです:
#include <iostream>
using namespace std;
#define N 24
// print:
//
// Prints the simulation matrix M as spaces, *'s, and T's.
//
void print(int M[][N], int ROWS, int COLS)
{
// YOU MUST IMPLEMENT THIS:
}
//
// fill:
//
// Fills the simulation matrix such that the boundary rows
// and columns are empty, the internal area is all trees,
// and one tree is burning at index position (row, col).
//
void fill(int M[][N], int ROWS, int COLS, int row, int col)
{
// YOU MUST IMPLEMENT THIS:
//
// main:
}//
int main()
{
int M[N/2][N];
int ROWS, COLS;
int r, c;
ROWS = sizeof(M) / sizeof(M[0]);
COLS = sizeof(M[0]) / sizeof(M[0][0]);
fill(M, ROWS, COLS, 1, 1);
for(r=0; r< ROWS; r++)
{
for(c=0; c< COLS; c++)
{
if(ROWS>1)
{
M[ROWS][COLS]=1;
cout<< M[ROWS][COLS];
}
else
{
M[ROWS][COLS]=0;
cout<< M[ROWS][COLS];
}
}
cout<< endl;
}
print(M, ROWS, COLS);
return 0;
}
これはどのように行うことができますか?