Guest User

Untitled

a guest
Apr 25th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include <string>
  5. #include <iomanip>
  6. using namespace std;
  7.  
  8. int welcome();
  9. int initialization(int &dimensions);
  10. void generateMagic(int &horizontal[], int dim, int &rowpos, int &activePos)
  11. void checkMagic(int dimensions, int horizontal, bool solution);
  12. void displayMagic(bool solution, int horizontal, int dimensions);
  13. bool repeat();
  14.  
  15. int main()
  16. {
  17. int rowpos = 0;
  18. int activePos[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
  19. int horizontal[13]={0,0,0,0,0,0,0,0,0,0,0,0,0};
  20. int dimensions = 0; bool solution = false;
  21. do{
  22.     welcome();
  23.     initialization();
  24.     do{
  25.         generateMagic(dimensions, horizontal);
  26.         checkMagic(dimensions, horizontal, solution);
  27.         displayMagic(solution, horizontal, dimensions);
  28.         }
  29.     while();
  30.  
  31.  
  32.       system("PAUSE");
  33.       return 0;
  34.  
  35. }
  36.  
  37.  
  38. void generateMagic(int &horizontal[], int dim, int &rowpos, int &activePos)
  39. {
  40.  
  41. horizontal[rowpos]++;
  42.  
  43. if (horizontal[rowpos] == dim) {
  44.    horizontal[rowpos]=activePos[rowpos];
  45.    if (rowpos == dim){activePos[]}
  46.    
  47.    
  48.    }
  49. rowpos++;
  50. }
  51.  
  52.    
  53.  
  54.  
  55.  
  56. /*for (int k = 0; k < dim; k++){
  57.     for (int j = 0; j < dim; j++){
  58.         int colc = 0;
  59.         if(horizontal[k] == horizontal[j]) colc++;
  60.         if(colc == 2){vertcheck = false; return;}
  61.         vertcheck = true;
  62.     }
  63. }
  64. */    
  65. }
  66.  
  67.  
  68. void welcome()
  69. {
  70.      cout<<"This is a working attempt to solve and graphically"<<endl
  71.      <<"output all valid combinations where eight queens can be"<<endl
  72.      <<"placed on a standard chessboard without any queen vulnerable to another."<<endl<<endl;
  73. }
  74.  
  75. void initialization(&dimensions)
  76. {
  77.      cout<<"How long do you want the edges of your square board to be?"<<endl<<endl
  78.      <<"Length: ";
  79.      cin>>dimensions;
  80.      if (dimensions >= 12)
  81.      {
  82.      cout << string(50, '\n');
  83.      cout<<endl<<"Sorry, but that number is too large to solve in a reasonable amount of time"<<endl
  84.      <<"Please choose a number smaller than 12"<<endl;
  85.      cin.ignore();
  86.      initialization();
  87.      }
  88. }
Add Comment
Please, Sign In to add comment