Hi, my code will not compile correctly. i have everything written and in order, there are only 2 errors but i don't know how to fix them. any help will be greatly appreciated.
here are the errors:
113 a function-definition is not allowed here before '{' token
113 expected `,' or `;' before '{' token
113 At global scope:
174 expected declaration before '}' token
#include <iostream>
#include <cstdlib>
usingnamespace std;
constint ROWS = 20;
constint COLS = 50;
void initialize ( char toads[][COLS+2] )
{
int row, col;
// Fill all 22 rows and 52 cols with '.'
for (row = 0; row < ROWS;row ++)
{
for (col = 0; col < COLS+2;col ++)
{
toads [row][col]= '.';
}
}
row=rand()%(row+1); // Select a random row number using rand() mod the number of rows plus one
col=rand()%(col+1); // Select a random column number using rand() mod the number of columns plus 1
toads[row][col]='A'; // Place an 'A' (Adult) in location (row,col) of the toads array
}
bool full ( char toads[][COLS+2] )
{
// Return true if all 20x50 interior cells are Adults
int row, col, i ;
for (row = 0; row < ROWS;row ++)
{
for (col = 0; col < COLS+2;col ++)
{
if(toads[row][col]!= 'A');
{
i++;
}
if ( i==0)
{
returntrue;
}
elsereturnfalse;
{
void propagate ( char toads[][COLS+2] );
}
// For all 20 rows and 50 columns of interior cells
// Convert any neighboring '.' cells to 'b' (baby)
int row, col;
for (row = 0; row < ROWS;row ++)
{
for (col = 0; col < COLS+2;col ++)
{
if (toads[row-1][col-1]=='A');
{
if (toads[row][col]=='.');
{
toads[row][col]='b';
}
if (toads [row-1][col]=='.');
{
toads[row-1][col]='b';
}
if(toads [row-2][col]=='.');
{
toads[row-2][col]='b';
}
if (toads [row-2][col-1]=='.');
{
toads[row-2][col-1]='b';
}
if (toads[row-2][col-1]=='.');
{
toads [row-2][col-1]='b';
}
if (toads[row-1][col-2]=='.');
{
toads[row-1][col-2]='b';
}
if (toads[row][col-2]=='.');
{
toads[row][col-2]='b';
}
if (toads[row][col-1]=='.');
{
toads[row][col-1]='b';
}
if (toads[row][col]=='.');
{
toads[row][col]='b';
}
}
void maturate ( char toads[][COLS+2] )
{
int row, col;
for (row = 0; row < ROWS;row ++)
// For all 20 rows and 50 columns of interior cells
// Convert any 'b' cells (baby) to 'A' (Adult)
{
for (col = 0; col < COLS+2;col ++)
{
if(toad[row][col]=='A';
{
toad[row][col]='b';
}
}
void print ( char toads[][COLS+2] )
{
// Print all 20 rows and 50 columns of the toads array
int row, col,blank ;
for (row = 0; row < ROWS;row ++)
{
for (col = 0; col < COLS+2;col ++)
{
cout<<toads[row][col];
if(col==50);
{
cout<<endl;
}
getline(cin,blank);
// Use getline to force the user to press return
}
int main()
{
char toads[ROWS+2][COLS+2];
// Seed the random number generator with the number of seconds since the
// beginning of the UNIX epoch (Jan. 1, 1970).
srand(time(NULL));
// Fill the toads array with dots and one randomly placed Adult toad
initialize ( toads );
while ( !full(toads) )
{
propagate(toads);
print(toads);
maturate(toads);
}
}
}
}
}
}
}
}
}
}
}
}
system("PAUSE");return 0;
}
}