I am having trouble figuring this out. I only have one error and it is in main. I am trying to write a program that will output first just a random sudoku type grid(function called random), then I am trying to output a sudoku type grid that has no duplicates in only the rows.(funciton called rows) I haven't ran it yet because it hasn't compiled. The one error it returns is:
line 37: Error: columns is not defined. in main... its in bold, below
these are all seperate files because that is the way our professor wanted them
any help would be greatly appreciated!!!!!!!!!!!!!!!!!!!1
main.cpp
#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
int algorithm(void);
int code(string);
int random (int grid[][9], int i, int j);
int print(int grid[][9], int rows, int columns);
int rows(int grid[][9], int rows, int columns);
int main()
{
int result;
int grid[9][9];
int i, j;
result = code("main.cpp"); // reads and prints code file
result = code("print.cpp"); // reads and prints code file
result = code("random.cpp"); // reads and prints code file
result = code("rows.cpp"); // reads and prints code file
if(result !=0)
cout<<"Error!";
else
//call function
random(grid,i,j);
rows(grid, 9, 9);
[B]print(grid, rows, columns);[/B]
}
random.cpp
# include <iostream>
# include <ctime>
# include <iomanip>
using namespace std;
//print prototype
int print(int grid[][9], int rows, int columns);
int random (int grid[][9], int i, int j)
{
srand(time(0));
for (i=0; i<9; i++)
{
for (j=0; j<9; j++)
{
grid[i][j] = rand()%9 + 1;
}
print(grid, 9, 9);
}
return 0;
}
print.cpp
#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
int print(int grid[][9], int rows, int columns)
{
for (int i=0; i <rows; i++)
{
for (int j=0; j < columns; j++)
{
cout << grid[i][j] << ' ';
}
cout << endl;
}
return 0;
}
rows.cpp
#include <iostream>
#include <ctime>
//prototype
int print(int grid, int rows, int columns);
void rows(int grid[][9], int row, int column)
{
int i, j, check=0;
srand(time(0));
for(j=0; j <column; j++)
{
for(i=1; i<row; i++)
{
random();
for(check=0; check<i; check++)
{
if(grid[check][j] == grid[i][j])
grid[i][j]= rand()%9+1;
break;
}
}
}
return;
}