没有合适的资源?快使用搜索试试~ 我知道了~
Peg solitaire CppBFS版
需积分: 10 12 下载量 14 浏览量
2011-10-05
17:46:02
上传
评论 2
收藏 6KB TXT 举报
温馨提示
试读
10页
Peg solitaire CppBFS版
资源推荐
资源详情
资源评论
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<iomanip>
#include<cstring>
#include<fstream>
using namespace::std;
////////////////////////////////////////////////////////////////////////////////////////////////////
//////////Timer/////////////////////////////////////////////////////////////////////////////////////
clock_t start, finish;
double duration;
void ClockStart()
{
start=clock();
}
void ClockStop()
{
finish=clock();
duration=(double)(finish - start)/CLOCKS_PER_SEC;
cout<<"-------------------------------------------------------------------------------"<<endl<<
"It takes "<<setprecision(2)<<duration<<" seconds to find the steps."<<endl<<
"--------------------------------------------------------------------------------"<<endl;
}
//////////End Timer/////////////////////////////////////////////////////////////////////////////////
//////////File Function/////////////////////////////////////////////////////////////////////////////
void InputFile(int &temp);
int filehash=-1;
//////////End File Function/////////////////////////////////////////////////////////////////////////
//////////Class Defination//////////////////////////////////////////////////////////////////////////
const int MAX=33554432;
int form[MAX]; //记录前一步的位置 -1为未搜索
int quene[MAX]; //记录搜索过的及将要搜索的值
class FORM
{
private:
int original,target,start,end,temp; //给定棋局hash值,结束棋局hash值,当前quene指针,末尾quene指针
char board[5][5]; //临时完整棋局
public:
FORM(); //构造函数
void Output(int hashvalue); //用给定hash值输出完整棋局
void Hash(int & temp,char board[][5]); //hash
void Dehash(int temp,char board[][5]); //逆hash
bool Search(); //搜索步法0有解1无解
int Writestep(int n); //给出解棋局的每一步
bool Check(int x,int y); //检查数据合法性 1不合法0合法
bool InputFile(int &temp); //载入数据//0succeed 1fail
//////////File Function/////////////////////////////////////////////////////////////////////////////
void InputFile(int &temp);
int filehash=-1;
//////////End File Function/////////////////////////////////////////////////////////////////////////
//////////Class Defination//////////////////////////////////////////////////////////////////////////
const int MAX=33554432;
int form[MAX]; //记录前一步的位置 -1为未搜索
int quene[MAX]; //记录搜索过的及将要搜索的值
class FORM
{
private:
int original,target,start,end,temp; //给定棋局hash值,结束棋局hash值,当前quene指针,末尾quene指针
char board[5][5]; //临时完整棋局
public:
FORM(); //构造函数
void Output(int hashvalue); //用给定hash值输出完整棋局
void Hash(int & temp,char board[][5]); //hash
void Dehash(int temp,char board[][5]); //逆hash
bool Search(); //搜索步法0有解1无解
int Writestep(int n); //给出解棋局的每一步
bool Check(int x,int y); //检查数据合法性 1不合法0合法
bool InputFile(int &temp); //载入数据//0succeed 1fail
剩余9页未读,继续阅读
资源评论
yyz999
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功