Alternative Sudoku Solver Input
Apr 28, 2012 at 10:54pm UTC
Hi. I just got a Sudoku solver up and running. There is one thing that's bugging me though. I have to type in the column, row, and value for each square in command prompt one number at a time (I normally don't use GUI), and it takes some time to do that. How could I set up a 9x9 thing of input boxes to make it a little easier and faster? Here is the input function i have right now:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
void Input()
{
Num_Known_Values = 0;
while (1)
{
if (User_Input) // These several lines of code are what I want to replace.
{
Display_Contradictory = true ;
cout << "Column: " ;
cin >> Input_Column;
cout << "Row: " ;
cin >> Input_Row;
cout << "Value: " ;
cin >> Input_Value;
cout << "\n" ;
Input_Row--;
Input_Column--;
}
else // This is just automatic random input for testing purposes.
{
Display_Contradictory = false ;
Input_Column = (rand() % (9 - 0)) + 0;
//cout << "\nColumn: " << Input_Column + 1;
Input_Row = (rand() % (9 - 0)) + 0;
//cout << "\nRow: " << Input_Row + 1;
Input_Value = (rand() % (9 - 0)) + 1;
//cout << "\nValue: " << Input_Value << "\n";
}
if ( (Input_Value > 0 && Input_Value < 10 && (!Check_Contradictory_Values (Input_Column, Input_Row, Input_Value))) || Input_Value == 0)
{
Known [Input_Column][Input_Row] = Input_Value;
// This is where the number gets stored after being made sure it is a "legal" move in Sudoku.
//Ex. no two numbers can be in the same row or column.
if (Input_Value = 0)
{
Possibilities_Reset();
Eliminate_Possible_Using_Known();
}
}
if (Find_Num_Known() >= 17 && !User_Input)
{
break ;
}
else if (Find_Num_Known() >= 0 && Input_Value == 10)
{
break ;
}
else if (Input_Value == -1)
{
Known_Reset();
Possibilities_Reset ();
}
Display_Known();
}
}
Last edited on Apr 28, 2012 at 10:55pm UTC
Topic archived. No new replies allowed.