2011年7月16日

poj-1856 Sea Battle *

摘要: /* * bfs * 又是一道水题。。1A * */#include <cstdio>#include <cstring>using namespace std;const int MAXN = 1000 + 5;int r, c; //同题意bool vis[MAXN][MAXN];char map[MAXN][MAXN];// sx,sy:矩形左上角。。ex,ey:矩形右下角..tot:矩形数。。。flag:是否正确int sx, sy, ex, ey, tot, flag;//获得ex,ey.. 若不是矩形,返回falsebool inline get_cor(i 阅读全文

posted @ 2011-07-16 21:06 龙豆 阅读(330) 评论(0) 推荐(0)

非递归遍历二叉树[转]

摘要: 【转】http://blog.csdn.net/kofsky/article/details/28864531.先序遍历从递归说起voidpreOrder(TNode*root){if(root!=NULL){Visit(root);preOrder(root->left);preOrder(root->right);}}递归算法非常的简单。先访问跟节点,然后访问左节点,再访问右节点。如果不用递归,那该怎么做呢?仔细看一下递归程序,就会发现,其实每次都是走树的左分支(left),直到左子树为空,然后开始从递归的最深处返回,然后开始恢复递归现场,访问右子树。其实过程很简单:一直往左走 阅读全文

posted @ 2011-07-16 19:43 龙豆 阅读(591) 评论(0) 推荐(0)

导航