asweetroxxi 0 Newbie Poster

i have the shell of the code but im have some trubble i need to write the function that lets the user input a zero or a one. it have to be done in a loop

the shell is shown:

#include <iostream>
using namespace std;
int const MAX_ROW=10;
int const MAX_COL=10;
int grid [MAX_ROW][MAX_COL];
void load_grid (int binArray[][10])
{

}
int count_something(int[][10],int,int);
void main()
{

}

int count_something(int grid[][10],int row, int col)
{
    if ( row<0||row>MAX_ROW||col<0||col>MAX_COL)
        return(0);
    else
        if (grid [row][col]==0)
            return(0);
        else
        {
            grid[row][col]=0;
            return( 1+count_something(grid,row+1,col-1)
                +count_something(grid, row+1,col)
                +count_something(grid,row+1,col+1)
                +count_something(grid,row,col+1)
                +count_something(grid,row,col-1)
                +count_something(grid,row-1,col+1)
                +count_something(grid,row-1,col)
                +count_something(grid,row-1,col-1));
        }
}

when i input the loop into the program it wont run in the void load_grid and when i input into the main it wont stop saying error
iin this one the while loop is shown:

#include <iostream>
using namespace std;
int const MAX_ROW=10;
int const MAX_COL=10;
int grid [MAX_ROW][MAX_COL];
void load_grid (int binArray[10][10])
{

}
int count_something(int[10][10],int,int);
void main()
{
    int num;
    cout<<" enter a one or zero; ";
    cin>> num;
    while (num!=1||num!=0)
    {
        cout<<" error ";
    }
}

int count_something(int grid[][10],int row, int col)
{
    if ( row<0||row>MAX_ROW||col<0||col>MAX_COL)
        return(0);
    else
        if (grid [row][col]==0)
            return(0);
        else
        {
            grid[row][col]=0;
            return( 1+count_something(grid,row+1,col-1)
                +count_something(grid, row+1,col)
                +count_something(grid,row+1,col+1)
                +count_something(grid,row,col+1)
                +count_something(grid,row,col-1)
                +count_something(grid,row-1,col+1)
                +count_something(grid,row-1,col)
                +count_something(grid,row-1,col-1));
        }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.