soduku - /soduku.cpp #include <iostream> #include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
//soduku.cpp #include <iostream> #include <fstream> #include <stdlib.h> using namespace std; void LoadFile( char * filename, int board[81]); void PrintBoard( char * filename, int board[81]); bool UseDigit( int board[81], int digit, int i, int j); int * Solver( int board[81]); int main() { int * board = new int [81]; LoadFile( "soduku.txt" ,board); board = Solver(board); PrintBoard( "output.txt" , board); system( "pause" ); //omit if not using windows return 0; } void LoadFile( char * filename, int board[81]) { ifstream in(filename); int input, i, j; for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { in >> input; board[i*9 + j] = input; } } in.close(); } void PrintBoard( char * filename, int board[81]) { int i, j; ofstream out(filename);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
if (board == NULL) { out << "No Solution\n\n" ; cout << "No Solution\n\n" ; out.close(); return ; } for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { cout << board[i*9 + j]; out << board[i*9 + j] << " " ; } cout << endl; out << endl; } cout << endl; out.close();
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

soduku - /soduku.cpp #include &lt;iostream&gt; #include...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online