文章分类 -  python

图深度遍历的一题
摘要:本文章原发于博客园,其他可能是本人的日志同步问题: 输入一个n*n的方块,统计连块的个数,连块就是有公共的边或者顶点代码:mat = []def init_mat(n): for i in range(0,n+2): # add the edge of the mat mat.append([0] * (n+2)) define_mat(n+1)def define_mat(n): c = 0 stop = 'n' while stop != 'y': row = input("row?: ") col =... 阅读全文

posted @ 2011-10-19 15:08 samael 阅读(209) 评论(0) 推荐(0)

珍爱生命,多用python
摘要:一道二叉树重建的问题,用C被折磨得不轻,干脆用python做了,一切清爽了不少。一道二叉树重建的问题,用C被折磨得不轻,干脆用python做了,一切清爽了不少。问题:输入二叉树的前序与中序,输出二叉树的后序本文章来自博客园,如果在别的地方看可能是本人的博客同步代码1 C代码 2 python 代码 1 C代码#include<stdio.h>#include<stdlib.h>#include<string.h>const int MAXN = 256;typedef struct TNode{ int have_value; int v; struct T 阅读全文

posted @ 2011-10-17 20:18 samael 阅读(266) 评论(0) 推荐(0)

导航