文章分类 -  算法

图深度遍历的一题
摘要:本文章原发于博客园,其他可能是本人的日志同步问题: 输入一个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 阅读(225) 评论(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 阅读(276) 评论(0) 推荐(0)

离散数学第6版25页41题
摘要:本文章来自于博客园,其他地方出处可能是本人的日志同步 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 #define ROWS 17 5 #define COLS 17 6 7 char flag = 'a'; 8 char array[ROWS][COLS]; 9 int c_row, c_col; 10 int solution(int B_row, int B_col, 11 int row, int col, 12 int i_row, int i_col); 13 14 i... 阅读全文

posted @ 2011-09-12 21:19 samael 阅读(190) 评论(0) 推荐(0)

导航