zrq495
www.zrq495.com
摘要: map[i][j]=1 表示第i 个顶点指向第j个顶点;如果map[1][i]=1, map[i][j]=1, 则map[1][j]=1。代码如下;#include<iostream>#include<cstring>using namespace std;int map[100][100];int main(){ int i, j; char str[1000]; while(cin >> str) { while (strcmp(str, "0")) { int len=strlen(str); ... 阅读全文
posted @ 2012-08-01 21:08 zrq495 阅读(174) 评论(0) 推荐(0) 编辑
摘要: DFS代码如下: 1 #include<iostream> 2 3 using namespace std; 4 5 int m, n; 6 char map[102][102]; 7 int dir[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}; //标记8个方向 8 9 void dfs(int x, int y)10 {11 int i, xx, yy;12 for (i=0; i<8; i++) //扫描8个方向13 {14 ... 阅读全文
posted @ 2012-08-01 11:05 zrq495 阅读(227) 评论(0) 推荐(0) 编辑