Write your question here.
Hi everyone... I'm writing a program for sudoku puzzle. so I'm done creating the board. But my problem is I have no idea how to generate number inside in board. I need help.
Put the code you need help with here.
void main (){
//Descriptions and genral ideas
cout << "WELCOME TO SUDOKU " << endl;
cout << endl;
cout << "RULES: "<< endl;
cout << endl;
cout << "->You'll be given a 9x9 board with some numbers depending on which level of difficulty you choose to play."<< endl;
cout << endl;
cout << "->You have to arrange numbers from 1 to 9 so that a number shows up once in one row, one column and in a 3x3 box." << endl;
cout << endl;
cout << "So, let's get started" << endl;
cout << endl;
cout <<endl;
char dash[9][9];
for (int array=0; array<9; array++) {
for (int array2=0; array2<9; array2++) {
dash[array][array2]='_';
}
}
char row[9];
char column[9];
char num[81];
int length;
length=strlen(row);
//Replaces the _'s in the specified rows/columns and replaces them with the integer the user specified.
for (int i=0; i<length; i++) {
dash[row[i]][column[i]]=num[i];
}
//Builds the Sudoko board and outputs the full 9x9 array.
cout << " 0 1 2 3 4 5 6 7 8 " << endl;
cout << "-----------------------------------------" << endl;
int i=0;
for (int count=0; count<3; count++) {
for (int count2=0; count2<3; count2++) {
cout << "||_" << dash[count][count2*3] << "_|_" << dash[count][count2*3+1] << "_|_" << dash[count][count2*3+2] << "_";
}
cout << "||" << i << endl;
i++;
}
cout << "-----------------------------------------" << endl;
int j=3;
for (int count=3; count<6; count++) {
for (int count2=0; count2<3; count2++) {
cout << "||_" << dash[count][count2*3] << "_|_" << dash[count][count2*3+1] << "_|_" << dash[count][count2*3+2] << "_";
}
cout << "||" << j << endl;
j++;
}
cout <<"-----------------------------------------" << endl;
int z=6;
for (int count=6; count<9; count++) {
for (int count2=0; count2<3; count2++) {
cout << "||_" << dash[count][count2*3] << "_|_" << dash[count][count2*3+1] << "_|_" << dash[count][count2*3+2] << "_";
}
cout << "||" << z << endl;
z++;
}
cout << "-----------------------------------------" << endl;
system("pause");
}