程序应该输出12×24与所有的外线输出0和里面的人输出网格创建boundry 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;
}
这怎么办?
你的老师希望你输出一个网格。你为什么使用2-dim阵列? – harper 2013-03-18 05:03:38