/*
* solve 3*3 magic matrix problem, using recursive backtracking
* algorithm, using Stanford cs106b library, may needs improvement
* for potential bug & performance
* version: 0.1, date: May-30-2015, author: Wei Xing,
*/
#include <iostream>
#include <string>
#include "genlib.h"
#include "Grid.h"
#include "Set.h"
using std::cout;
using std::endl;
using std::string;
/* Private function prototype */
template<typename T>
void DisplayGrid(Grid<T> g);
bool CheckResult(Grid<int>& g);
void RecursiveSolve(Grid<int> g, Set<int> s);
/* Main function */
int main()
{
Set<int> s;
for (int i = 0; i < 9; i++) {
s.add(i+1);
}
Grid<int> g(3,3);
RecursiveSolve(g, s);
cout << "now all done!" << endl;
return 0;
}
/* Private function implementation */
template<typename T>
void DisplayGrid(Grid<T> g) {
for (size_t r
solve 3*3 magic square problem using recursive backtracking(using Stanford CS106b ADT library)
最新推荐文章于 2022-12-02 14:24:56 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)