Hello,
I have made a console project with sudoku, but I am having problems when executing it. Basically, the program is one big loop, where the user gets to choose to access menus and menu options. Sometimes when I choose the option to go out of one loop, the program might not recognize the same options if I return to the same loop. I'm also having problems displaying the solution to the puzzle. I'm not generating a random puzzle; rather, for each level, I'm using pre-determined puzzles that will be displayed at different times to the user. I have noticed that I am repeating a lot of the same code over and over, and I would like some guidance as to how it can be simplified and how it can be made to work properly. To let you know exactly what I am working with, I have a class.cpp file and class.h file that are used to build a library, class.lib. The main program is in a prog.cpp file.
Here is how the code looks like:
the class.h file:
CODE
#ifndef CLASS_H
#define CLASS_H
int const max=81;
void showMainMenu();
void showLevelMenu();
void showPuzzleMenu();
void showCustomMenu();
void showCustomMenu2();
class puzzle {
int index;
public:
int cell;
char* chart;
puzzle();
~puzzle();
void generator(int level); //provides puzzles to be solved (non-random)
void printchart();
int findnextcell(); //function to find the next empty or '0' containing cell
int checkrow(); //function to check the current row, against the same number in a single row, return 0 or 1
int checkcolumn(); //check the current column for duplicate numbers
int checkblock(); // Function to check the block for similar numbers and return 1 or 0
int check(); // Check function to return 0 or 1, integrates checking row, column, and block
int guess(); // Function to guess all the possibilities and solve the empty squares
};
#endif //CLASS_H
the class.cpp file:
CODE
#include <iostream>
#include <windows.h>
#include "class.h"
using namespace std;
void showMainMenu(){
//Main menu
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 270);
cout <<" Welcome to Sudoku! \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" Main Menu: Please choose one of the following options: \n\n"
" c --> Choose a new puzzle (9x9 board) \n"
" d --> Devise your own custom 9x9 puzzle \n"
" q --> Quit this program \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" Enter your choice here: ";
}
void showLevelMenu(){
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 270);
cout <<" Choose your puzzle level: \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" Decide on one of the following options: \n\n"
" b --> Beginner level puzzle \n"
" i --> Intermediate level puzzle \n"
" a --> Advanced level puzzle \n"
" e --> Expert level puzzle \n"
" m --> Return to the main menu \n"
" q --> Quit this program \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" Enter your choice here: ";
}
void showPuzzleMenu(){
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 270);
cout <<" Puzzle Menu: \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" At any time during the game, you can enter these options: \n"
" s --> Display the solution to your puzzle \n"
" m --> Return to the main menu (this option will delete your puzzle) \n"
" l --> Choose another level (this option will delete your puzzle) \n"
" d --> Delete your puzzle and start a new one (this option redisplays this menu)\n"
" q --> Quit this program \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" Press the Enter key to begin playing your sudoku puzzle: ";
}
void showCustomMenu(){
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 270);
cout <<" Custom Puzzle Menu \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" n --> Create a new custom puzzle \n"
" m --> Return to the main menu \n"
" q --> Quit this program \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" Enter your choice here: ";
}
void showCustomMenu2(){
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 270);
cout <<" Custom Puzzle Menu (continued): \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 271);
cout <<" At any time when creating your puzzle or playing sudoku with it, these options \n"
" are available: \n"
" p --> Play sudoku with your puzzle \n"
" s --> Display the solution to your puzzle \n"
" m --> Return to the main menu (this option will delete your puzzle) \n"
" r --> Return to the previous menu (this option will delete your puzzle) \n"
" d --> Delete your puzzle and start over (this option redisplays this menu) \n"
" q --> Quit this program \n";
SetConsoleTextAttribute(hConsole, 267);
cout <<& #34;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n";
SetConsoleTextAttribute(hConsole, 271);
}
puzzle::~puzzle(){
delete []chart;
cell=0;
}
puzzle::puzzle() : cell(0) {
chart=new char[max];
}
void puzzle::generator(int level){
static int counter=1;
if (level==0){
for(int i=0;i<max; i++)
chart[i] = 0;
}
if (level==1){
if (counter==1){
char chart1[& #93;={7,0,0,0,0,4,8,0,2,0,0,0,9,0,0,0,6,3,0,9,0,7,3,0,0,0,0,0,8,6,0,0,1,4,0,0,3,
2,4,0,0,0,6,1,9,0,0,1,4,0,0,2,3,0,0,0,0,0,9,7,0,8,0,8,5,0,0,0,3,0,0,0,6,0,9,5,0,
0,0,0,7};
for(int i=0;i<max; i++)
chart[i] = chart1[i];
}
if (counter==2){
char chart1a[& #93;={0,0,0,0,0,0,6,0,3,6,0,0,2,0,8,5,1,0,0,5,0,6,0,3,0,2,7,7,4,1,0,3,0,8,6,0,0,
0,0,0,0,0,0,0,0,0,6,2,0,7,0,9,3,5,9,1,0,3,0,7,0,5,0,0,8,3,1,0,4,0,0,6,5,0,6,0,0,
0,0,0,0};
for(int i=0;i<max; i++)
chart[i] = chart1a[i];
}
if (counter==3){
char chart1b[& #93;={0,2,1,7,0,9,3,5,8,0,9,3,0,8,0,0,0,1,8,4,0,0,0,0,0,0,0,2,0,0,9,0,1,0,6,0,0,
0,0,0,6,0,0,0,0,0,1,0,4,0,8,0,0,9,0,0,0,0,0,0,0,7,2,4,0,0,0,1,0,5,8,0,1,5,2,8,0,
6,9,4,0};
for(int i=0;i<max; i++)
chart[i] = chart1b[i];
}
if (counter==4){
char chart1c[& #93;={0,7,4,0,3,0,9,6,8,0,2,0,6,0,9,0,3,0,6,0,0,0,0,0,2,0,7,0,8,0,1,0,0,6,9,0,3,
0,0,0,0,0,0,0,5,0,5,1,0,0,6,0,8,0,8,0,9,0,0,0,0,0,6,0,4,0,3,0,8,0,7,0,7,1,6,0,4,
0,8,2,0};
for(int i=0;i<max; i++)
chart[i] = chart1c[i];
}
if (counter==5){
char chart1d[& #93;={0,0,0,0,5,9,1,0,4,5,0,0,0,0,0,8,0,0,0,0,7,0,2,8,0,6,0,2,5,0,1,9,0,0,8,0,6,
0,4,0,3,0,9,0,2,0,9,0,0,6,2,0,3,5,0,7,0,9,8,0,2,0,0,0,0,8,0,0,0,0,0,7,4,0,2,5,1,
0,0,0,0};
for(int i=0;i<max; i++)
chart[i] = chart1d[i];
}
if (counter==6){
counter=0;
generator(level);
}
}
if (level==2){
if (counter==1){
char chart2[& #93;={0,0,0,0,0,8,0,9,7,0,0,2,0,0,0,0,0,0,0,0,0,5,1,4,0,0,3,5,7,0,0,2,1,0,6,0,0,
9,1,0,6,0,4,2,0,0,4,0,9,8,0,0,7,1,9,0,0,8,7,6,0,0,0,0,0,0,0,0,0,9,0,0,4,2,0,1,0,
0,0,0,0};
for(int i=0;i<max; i++)
chart[i] = chart2[i];
}
if (counter==2){
char chart2a[& #93;={2,0,3,0,5,0,7,1,0,9,0,0,7,8,0,6,0,3,0,0,5,0,0,0,0,2,4,0,0,0,3,1,0,0,0,0,0,
9,0,0,0,0,0,8,0,0,0,0,0,7,6,0,0,0,7,2,0,0,0,0,9,0,0,5,0,9,0,6,7,0,0,8,0,6,8,0,4,
0,2,0,5};
for(int i=0;i<max; i++)
chart[i] = chart2a[i];
}
if (counter==3){
char chart2b[& #93;={9,1,0,8,5,0,0,0,0,0,2,0,9,0,0,0,0,8,7,5,8,0,0,0,0,0,0,1,0,0,0,0,3,4,7,0,5,
0,0,0,0,0,0,0,9,0,3,7,4,0,0,0,0,5,0,0,0,0,0,0,9,2,4,3,0,0,0,0,2,0,6,0,0,0,0,0,4,
7,0,1,3};
for(int i=0;i<max; i++)
chart[i] = chart2b[i];
}
if (counter==4){
char chart2c[& #93;={0,3,0,0,8,2,0,0,5,1,0,0,7,0,0,0,0,0,6,2,0,3,0,5,0,0,0,0,0,1,0,2,0,0,0,3,0,
8,0,5,7,4,0,6,0,5,0,0,0,1,0,2,0,0,0,0,0,8,0,1,0,4,6,0,0,0,0,0,7,0,0,1,8,0,0,4,5,
0,0,9,0};
for(int i=0;i<max; i++)
chart[i] = chart2c[i];
}
if (counter==5){
char chart2d[& #93;={0,1,0,0,7,0,0,3,0,4,0,0,8,3,0,0,0,0,9,8,0,1,0,0,0,0,7,0,0,0,9,0,0,5,2,0,1,
0,0,0,0,0,0,0,3,0,5,2,0,0,3,0,0,0,2,0,0,0,0,1,0,6,9,0,0,0,0,9,6,0,0,1,0,9,0,0,5,
0,0,7,0};
for(int i=0;i<max; i++)
chart[i] = chart2d[i];
}
if (counter==6){
counter=1; //resetting counter to 1
generator(level);
}
}
if (level=3){
if (counter==1){
char chart3[& #93;={0,0,6,0,0,0,0,0,1,1,0,0,0,6,0,2,7,8,0,0,4,0,9,0,0,6,0,2,0,9,0,0,0,0,0,0,6,
0,0,7,0,9,0,0,3,0,0,0,0,0,0,6,0,7,0,6,0,0,3,0,4,0,0,9,1,3,0,5,0,0,0,6,5,0,0,0,0,
0,1,0,0};
for(int i=0;i<max; i++)
chart[i] = chart3[i];
}
if (counter==2){
char chart3a[& #93;={0,9,0,3,1,0,0,6,5,2,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,4,8,0,5,0,0,0,8,9,0,0,3,
0,0,0,0,0,0,0,6,0,0,7,1,0,0,0,5,0,9,6,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,2,5,4,0,0,3,
2,0,8,0};
for(int i=0;i<max; i++)
chart[i] = chart3a[i];
}
if (counter==3){
char chart3b[& #93;={0,0,0,0,8,3,0,0,0,2,3,0,0,0,7,5,0,0,0,0,4,0,0,0,0,0,1,0,0,0,0,7,5,0,0,0,0,
8,9,6,2,1,7,5,0,0,0,0,4,9,0,0,0,0,7,0,0,0,0,0,4,0,0,0,0,1,7,0,0,0,2,9,0,0,0,9,1,
0,0,0,0};
for(int i=0;i<max; i++)
chart[i] = chart3b[i];
}
if (counter==4){
char chart3c[& #93;={5,6,0,7,0,0,0,0,0,0,0,2,0,0,4,0,6,0,0,0,3,8,0,0,0,5,1,0,0,8,2,0,0,0,0,0,9,
0,6,0,0,0,2,0,5,0,0,0,0,0,9,6,0,0,4,3,0,0,0,5,7,0,0,0,7,0,9,0,0,8,0,0,0,0,0,0,0,
7,0,9,4};
for(int i=0;i<max; i++)
chart[i] = chart3c[i];
}
if (counter==5){
char chart3d[& #93;={0,0,4,0,5,7,3,0,0,0,0,0,0,0,0,0,0,1,0,7,0,3,0,0,0,9,0,0,0,0,0,1,8,0,0,4,7,
0,5,0,6,0,9,0,8,4,0,0,5,7,0,0,0,0,0,4,0,0,0,1,0,6,0,1,0,0,0,0,0,0,0,0,0,0,8,9,3,
0,2,0,0};
for(int i=0;i<max; i++)
chart[i] = chart3d[i];
}
if (counter==6){
counter=1; //resetting counter to 1
generator(level);
}
}
if (level=4){
if (counter==1){
char chart4[& #93;={0,0,0,0,5,0,7,2,0,6,0,0,0,9,0,0,1,0,4,0,0,1,0,0,0,0,3,0,0,0,0,0,0,6,5,2,7,
0,0,0,0,0,0,0,4,5,2,6,0,0,0,0,0,0,3,0,0,0,0,7,0,0,1,0,7,0,0,2,0,0,0,6,0,9,1,0,3,
0,0,0,0};
for(int i=0;i<max; i++)
chart[i] = chart4[i];
}
if (counter==2){
char chart4a[& #93;={9,5,0,6,0,0,0,0,0,0,7,2,0,0,0,0,1,0,0,0,3,0,0,8,0,0,0,0,0,0,0,8,0,0,0,5,0,
8,0,2,5,3,0,7,0,1,0,0,0,4,0,0,0,0,0,0,0,4,0,0,8,0,0,0,2,0,0,0,0,3,4,0,0,0,0,0,0,
1,0,5,6};
for(int i=0;i<max; i++)
chart[i] = chart4a[i];
}
if (counter==3){
char chart4b[& #93;={0,5,0,0,9,2,0,0,4,2,0,0,0,0,7,1,0,0,8,0,0,0,0,0,0,0,0,0,1,0,6,0,0,9,0,0,5,
0,6,0,0,0,2,0,7,0,0,3,0,0,5,0,6,0,0,0,0,0,0,0,0,0,6,0,0,9,3,0,0,0,0,2,1,0,0,2,8,
0,0,9,0};
for(int i=0;i<max; i++)
chart[i] = chart4b[i];
}
if (counter==4){
char chart4c[& #93;={0,0,0,5,2,0,0,1,0,0,5,4,0,0,0,6,0,0,7,0,3,0,0,0,0,0,0,0,0,6,4,1,0,0,5,0,0,
0,0,7,0,3,0,0,0,0,3,0,0,8,2,7,0,0,0,0,0,0,0,0,2,0,6,0,0,1,0,0,0,4,3,0,0,4,0,0,6,
5,0,0,0};
for(int i=0;i<max; i++)
chart[i] = chart4c[i];
}
if (counter==5){
char chart4d[& #93;={0,0,0,7,0,0,5,0,0,0,0,0,4,6,0,3,0,1,5,3,0,0,0,0,0,7,6,0,0,0,0,0,1,0,9,4,0,
0,0,0,0,0,0,0,0,6,8,0,9,0,0,0,0,0,8,6,0,0,0,0,0,5,7,2,0,3,0,5,4,0,0,0,0,0,9,0,0,
6,0,0,0};
for(int i=0;i<max; i++)
chart[i] = chart4d[i];
}
if (counter==6){
counter=1; //resetting counter to 1
generator(level);
}
}
counter++;
}
void puzzle::printchart(){
int i, j;
cout<<" ";
for (i=0; i<9; i++)
cout<<(i+1)<<" ";
cout<<endl<<" -------------------------------------\n";
for (i = 0; i<9; i++){
cout<<" "<<(i+1)<<" | ";
for (j = 0; j<9; j++){
if (chart[i*9+j]==0)
cout<<" "" | ";
else
cout <<(int) chart[i*9+j] << " | ";
}
cout <<"\n -------------------------------------\n";
} cout<<"\n";
}
int puzzle::findnextcell(){
for(;cell<max; cell++)
if(!chart[cell])
break;
return cell;
}
int puzzle::checkrow(){
int savecell = chart[cell]; //the cell at hand
index=cell;
char *p = chart;
p+=(cell/9)*9; // Find the beginning of the row
index = index % 9; // Go to the beginning of the row
for (int i = 0; i< 9; i++)
{
if(i != index && p[i] == savecell)
return 0;
}
return 1;
}
int puzzle::checkcolumn(){
int savecell = chart[cell];
char *p = chart;
index = cell;
index-=(index/9)*9; // Find the beginning of the column
//
p+=index; // Go to the beginning of the column
//
index = index/9; // The cell at hand, so that the checker doesn't check the cell with itself and return a 0
for (int i = 0; i< 9; i++)
{
if(i != index && p[i*9] == savecell)
return 0;
}
return 1;
}
int puzzle::checkblock(){
int savecell = chart[cell];
char *p = chart;
int myindexi, myindexj;
index=cell;
myindexi = index/9;
myindexi = myindexi % 9;
myindexj = index % 3;
index = (index/3)*9; //go to the beginning of the block but stay in the same row
p+=index;
index/=9;
index = index%3;
index-=index*9;
for (int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
if(i != myindexi && j != myindexj &&
p[i*9+j] == savecell)
return 0;
return 1;
}
int puzzle::check(){
if(checkrow() && checkcolumn() && checkblock())
return 1;
else
return 0;
}
int puzzle::guess(){
cell=0;
cell = findnextcell();
if(cell == 81)
return 1;
for (int i = 1; i<=9; i++){
chart[cell]=i;
if(check()){
if(guess())
return 1;
else
continue;
}
else
continue;
}
chart[cell]=0;
return 0;
}
the prog.cpp file:
CODE
// OOP Using C++ Final Project, by Albaraa Salama and Brenda Casanova
// Spring 2008
#include <iostream>
#include <sstream>
#include <string.h>
#include "class.h"
using namespace std;
bool success, success1, success2, quit=false, quit2=false, quit3=false, quit4=false, quit5=false; //flags
int convertToInt(const string& s, bool& success){
istringstream i(s);
int x;
if (i>>x)
success=true; //indicates that the string contains an integer
else
success=false;
return x;
}
int main(){
string input, row, column;
int level;
showMainMenu();
cin>>input;
while (quit==false){
if (quit2)
quit2=false; //resetting level 2 flag
if(input== "q"){
system("cls");
cout<<"\n Thank you for your time!\n";
exit(0);
}
if(input=="c"){
system("cls"); showLevelMenu(); cin>>input;
while (quit2==false){
if (quit3)
quit3=false; //resetting level 3 flag
if (input=="q"){
system("cls");
cout<<"\n Thank you for your time!\n";
exit(0);
}
if (input=="m"){
system("cls"); quit2=true; showMainMenu(); cin>>input; continue;
}
if (input=="b"){
while (quit3==false){
if (quit4)
quit4=false; //resetting level 4 flag
system("cls"); showPuzzleMenu(); cin.get(); cin.get();
level=1;
puzzle a; a.generator(level);
while (quit4==false){
system("cls");
a.printchart();
cout <<"Enter the row and column numbers, separated by a space, for the square you want\n"
" to access (the row number is first): ";
cin>> row >> column;
convertToInt(row, success);
if (success)
success1=true;
else if (!success)
success1=false;
convertToInt(column, success);
if (success)
success2=true;
else if (!success)
success2=false;
if(success1 && success2)
success=true;
else
success=false;
if (success){
if ((convertToInt(row, success)>9 || convertToInt(row, success)<1) || (convertToInt(column, success)>9 || convertToInt(column, success)<1)){
system("cls");
if (convertToInt(row, success)>9 || convertToInt(row, success)<1)
cout<<"\n The row number you entered is not within the acceptable range\n"
" of numbers from 1 to 9.\n";
if (convertToInt(column, success)>9 || convertToInt(column, success)<1)
cout<<"\n The column number you entered is not within the acceptable range\n"
" of numbers from 1 to 9.\n";
cout<<"\n Press Enter to try again: ";
cin.get(); cin.get();
system("cls"); continue;
}
else if ((convertToInt(row, success)<=9 && convertToInt(row, success)>0) && (convertToInt(column, success)<=9 && convertToInt(column, success)>0)){
a.cell= (convertToInt(row, success)-1)*9+(convertToInt(column, success)-1);
}
}
if (success==false){
system("cls");
cout<<"\n One or more of the values you entered is not acceptable.\n"
" Please put in only numbers from 1 to 9.\n"
"\n If you want to enter a Puzzle Menu option, please wait until\n"
" you have the opportunity to enter a value into a square before doing so.\n"
"\n Press Enter to try again: ";
cin.get(); cin.get();
system("cls"); continue;
}
cout <<" Enter the value you want in the square: ";
cin >> input;
convertToInt(input, success);
if (success){
if (convertToInt(input, success)>9 || convertToInt(input, success)<1){
system("cls");
cout<<"\n The number you entered is not within the acceptable range\n"
edit: I realized that the code was cut off, so I won't be able to submit the full source code unless anyone wishes for me to send it through pm.
This post has been edited by bcasanov: 12 May, 2008 - 03:00 AM