- 博客(5)
- 资源 (1)
- 问答 (1)
- 收藏
- 关注
原创 Uva572——Oil Deposits
数油田的个数,简单的DFS。 代码: #include #include using namespace std; const int maxn = 100 + 5; int num[maxn][maxn]; char str[maxn][maxn]; int m, n; void dfs(int x, int y) { if(num[x][y] != 0 || str[x][y]
2016-02-29 22:04:00 346
原创 Uva297——Quadtrees
#include #include #include using namespace std; const int len = 32; const int maxn = 1024 + 6; int buff[len][len], count; char s[maxn]; void fun(char *str, int& pos, int r, int c, int w) { cha
2016-02-28 17:23:19 285
原创 Uva699——The falling leaves
输入的二叉树是先序遍历的形式,只是加上了各个叶子节点的左右孩子,都为-1. 在递归的过程中算出水平位置的权值。(水平位置的权值,可以通过+1(右边节点)或者-1(左边节点) 来对应) 代码: #include #include using namespace std; const int maxn = 10000 + 10; int sum[maxn]; void build
2016-02-28 16:29:49 323
原创 Uva839——Not so Mobile
判断天平是否平衡,W1 或 W2 为0,表示为子天平。递归过程中来输入并判断。 代码: #include using namespace std; bool fun(int& n) { int a1, b1, a2, b2; bool a = true, b = true; //a表示左是否平衡,b表示右是否平衡 cin >> a1 >> b1 >> a2 >> b2;
2016-02-28 15:04:30 255
原创 Uva548——Tree
这题主要是根据中序遍历和后序变量构造二叉树。 一开始用 的是二叉树的数组表示形式来求解,但是本题的数据量挺大的,数组不能完全表示出来。关键点是这题的所有数都小于10000.所以用两个数组 lch 和rch 来表示权值点的左右孩子的情况。 然后在通过dfs来查找叶子结点到根节点的最小权值的叶子。 代码: #include #include #include #include usin
2016-02-28 14:20:53 493
vs2013 fstream 无法打开文件
2015-03-10
TA创建的收藏夹 TA关注的收藏夹
TA关注的人