Example #1
0
 /// Print solution
 virtual void
 print(std::ostream& os) const {
   os << "\tNumber of Queens: " << q << std::endl;
   os << "\tBoard: " << b << std::endl;
   if (b.assigned()) {
     // Print a nice board
     bool* placed = new bool[n*n];
     for (int i=0; i<n*n; i++)
       placed[i] = false;
     for (int i=0; i<n*n; i++)
       placed[b[i].val()] = true;
     for (int j=0; j<n; j++) {
       std::cout << "\t\t";
       for (int i=0; i<n; i++)
         std::cout << (placed[xy(i,j)] ? 'Q' : '.') << ' ';
       std::cout << std::endl;
     }
     delete [] placed;
   }
   os << std::endl;
 }