恒邪

2014年4月26日 #

[数据结构] 迷宫问题(栈和队列,深搜和广搜)

摘要: 代码:#include #include #include #include #include using namespace std;int dx[4]={0,-1,1,0};//方向int dy[4]={-1,0,0,1};bool vis[6][6];int total=0;//多少可到达路径int sx=1,sy=1;//入口出口坐标int ex=4,ey=4;int num[10][10];//广搜时记录到达当前点的最少步数struct P{ int x,y;}point[40];//用来记录可到达路径struct PP{ int fx,fy;}path[10][10];... 阅读全文

posted @ 2014-04-26 12:55 恒邪 阅读(412) 评论(0) 推荐(0) 编辑

[数据结构] N皇后问题

摘要: 代码:#include #include #include using namespace std;const int N=100;int c[N];//皇后第i行放在第几列上int n,total;int cc;//方法数void dfs(int cur){ if(cur>n) { cout>n; if(n<=0) { cout<<"输入不合法,程序退出!"<<endl; break; } cc=1; total=0; dfs(1); ... 阅读全文

posted @ 2014-04-26 12:52 恒邪 阅读(303) 评论(0) 推荐(0) 编辑

导航