Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- #include <string>
- #include <iomanip>
- using namespace std;
- int welcome();
- int initialization(int &dimensions);
- void generateMagic(int &horizontal[], int dim, int &rowpos, int &activePos)
- void checkMagic(int dimensions, int horizontal, bool solution);
- void displayMagic(bool solution, int horizontal, int dimensions);
- bool repeat();
- int main()
- {
- int rowpos = 0;
- int activePos[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
- int horizontal[13]={0,0,0,0,0,0,0,0,0,0,0,0,0};
- int dimensions = 0; bool solution = false;
- do{
- welcome();
- initialization();
- do{
- generateMagic(dimensions, horizontal);
- checkMagic(dimensions, horizontal, solution);
- displayMagic(solution, horizontal, dimensions);
- }
- while();
- system("PAUSE");
- return 0;
- }
- void generateMagic(int &horizontal[], int dim, int &rowpos, int &activePos)
- {
- horizontal[rowpos]++;
- if (horizontal[rowpos] == dim) {
- horizontal[rowpos]=activePos[rowpos];
- if (rowpos == dim){activePos[]}
- }
- rowpos++;
- }
- /*for (int k = 0; k < dim; k++){
- for (int j = 0; j < dim; j++){
- int colc = 0;
- if(horizontal[k] == horizontal[j]) colc++;
- if(colc == 2){vertcheck = false; return;}
- vertcheck = true;
- }
- }
- */
- }
- void welcome()
- {
- cout<<"This is a working attempt to solve and graphically"<<endl
- <<"output all valid combinations where eight queens can be"<<endl
- <<"placed on a standard chessboard without any queen vulnerable to another."<<endl<<endl;
- }
- void initialization(&dimensions)
- {
- cout<<"How long do you want the edges of your square board to be?"<<endl<<endl
- <<"Length: ";
- cin>>dimensions;
- if (dimensions >= 12)
- {
- cout << string(50, '\n');
- cout<<endl<<"Sorry, but that number is too large to solve in a reasonable amount of time"<<endl
- <<"Please choose a number smaller than 12"<<endl;
- cin.ignore();
- initialization();
- }
- }
Add Comment
Please, Sign In to add comment