该程序应该输出一个 12x24 的网格,所有外部线输出 0,内部线输出 1
这是我为了让第一列和第一行输出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;
}
如何才能做到这一点?