To be honest, i'm really bad with c++ but it's required for my major. We have to make a sudoku program, that reads from a file, inputs the data into a 9 by 9 grid (of 2d array), inputs numbers till the grid is solved, then check for valid moves, and check when it is solved. I am stuck. This is what i have so far
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
class Sudoku
{
private:
int grid;
bool badRow(int row);
bool badCol(int col);
bool badSec(int row, int col);
public:
Sudoku()
{
}
void getPuzzle();
void display();
void submitMove(); //check if valid, input move(badcol, badrow, badsec)
bool isSolved();
};
void Sudoku::getPuzzle() {
const int row = 9;
const int col = 9;
int gameData[row][col];
ifstream inputFile;
inputFile.open("game1.txt");
if (!inputFile){
cout << "Error opening file!" << endl;
}
else {
//input data
for (int i=0; i < row; i ++)
for (int j=0; j < col; j++)
inputFile >> gameData[row][col];
}
}
void Sudoku::display() {
}
int main()
{
//declare/initialize variables
Sudoku puzzle;
puzzle.getPuzzle();
//begin solving loop
//while (puzzle.isSolved()= false)
//{
// puzzle.display();
// puzzle.submitMove();
//}
puzzle.display();
cout << "congratulations! You have solved the puzzle." << endl;
return (0);
}
//Read in puzzle, work to get it solved
any help or pointers would be amazing