So A friend and I are new to C++ and we are trying to create a sudoku project and are trying to figure out different ways to do so. Right now we are stuck at the repetition checking. I was wondering if anyone could help us out?? We are trying to figure out how to check a row of numbers for repetition our code so far for the checking is as follows...
#include <iostream>
#include <ctime>
using namespace std;
char rows(int grid[][9], int rows, int cols, char& choice)
{
//Variables
int i, j, k=1, strTime, stpTime, totTime;
bool repChecker = false;
srand (time (0));
strTime = time(0); //Initializes a starting time
//Creates the 2D array with out repititons in the rows
for(i=0; i<9; i++)
{
for(j=0; j<9; j++)
{
grid[i][j] = rand( )%9 + 1;
if(grid[i][j]==grid[i][j-k])
--j;
} // inner for loop
}
stpTime = time(0); //Initializes a stopping time
totTime = stpTime - strTime; //Calculates the total time used to create the random grid
cout << "It took a total of " << totTime << " to create a random 9 X 9 grid.";
cout << "\n\nIf you would like to create another grid type \"W\" otherwise type \"M\" to go back to the main menu: ";
cin >> choice;
return 0;
}
any help would be appreciated thanks :-)