I am a beginner in C++ programming. I was trying to make a Sudoku solver by Brute Force, but I just cant seem to figure out whats amiss.

I have tried to assign random unique numbers to each row and each column. Theoretically, by using unrelated random numbers, this is bound to give me a solution for the sudoku.

Can someone help me make this thing work ?

Code:

#include <iostream.h>

#include <conio.h>

#include <stdlib.h>

#include <time.h>

void main()

{

srand(time(NULL));

int arr[9][9];

int full[9][9];

cout << "INSTRUCTIONS!";

cout << endl << "Enter the initial Sudoku square";

cout << "\\nEnter the numbers where they appear, or enter 0 if there is a blank space\n\n";

//counters

int i=0,j=0;

for(i=0;i<9;i++)

{

for(j=0;j<9;j++)

{

full[i][j]=0;

cout << "Enter the element at " << (i+1) << "," << (j+1) << ": ";

cin >> arr[i][j];

if(arr[i][j]!=0)

full[i][j]=1;

}

}

clear1: clrscr();

for(i=0;i<9;i++)

{

for(j=0;j<9;j++)

{

cout << arr[i][j] << "\t";

}

cout << endl;

}

for(i=0;i<9;i++)

{

for(j=0;j<9;j++)

{

if(full[i][j]==0)

{

int x= random(1000);

x=(x%9)+1;

arr[i][j]=x;

}

}

}

clrscr();

//horizontal check

for(i=0;i<9;i++)

{

int flag=1;

for(j=0;j<9;j++)

{

for(int J=(j+1);J<9;J++)

{

if(arr[i][j]==arr[i][J])

goto clear1;

}

}

}

//vertical check

for(j=0;j<9;j++)

{

int flag=1;

for(i=0;i<9;i++)

{

for(int I=(i+1);I<9;I++)

{

if(arr[i][j]==arr[I][j])

goto clear1;

}

}

}

//subgrid check

// to be implemented after horizontal+vertical checks are done

for(i=0;i<9;i++)

{

for(j=0;j<9;j++)

{

cout << arr[i][j] << "\t";

}

cout << endl;

}

getch();

clrscr();

}