DFS
AioRos128
加油
展开
-
宝岛探险
dfs问题,宝岛探险,求出所在岛屿的面积 #include using namespace std; const int maxn=200; int next[4][2]={{0,1},{1,0},{0,-1},{-1,0}};//右,下,左,上 int map[maxn][maxn];//宝岛地图 int flag[maxn][maxn]; //标记 int sx,sy;//开始坐标 int原创 2016-04-25 13:45:50 · 719 阅读 · 0 评论 -
皇后问题
//一个变化问题,要输出指定的皇后序列 //注释里的那段代码效率比较低 //去掉m变量就是n皇后问题 #include using namespace std; int n=8,m; int c[10]; int vis[10][100]; void dfs(int cur) { if(cur==n && (m--==1) ) { for(int i=0;i<n;i++) cout<<c原创 2016-04-20 13:20:17 · 345 阅读 · 0 评论 -
填格子
#include #include #include #include #include using namespace std; int flag[3][4]; ///判断每个位置是否可以放数 bool vis[10]; int a[3][4]; ///每个位置进行放数 int sum = 0; int s[8][2] = {{转载 2017-03-25 11:28:23 · 558 阅读 · 0 评论