
编程之美
文章平均质量分 79
xw_njust_ecjtu
沉淀
展开
-
编程之美 -- 只考虑加法的面试题,程序理解和分析
先考虑-- 只考虑加法的面试题转载 2014-04-23 17:14:27 · 668 阅读 · 0 评论 -
精确表达浮点数 -- 编程之美
#include #include #include #include using namespace std;struct Fraction{ int Denominator; int numerator;};int gcd(int x,int y);int simple_gcd(int x,int y);Fraction deal_num(string str);原创 2014-04-16 11:26:05 · 914 阅读 · 0 评论 -
堆排序,以及stl中的堆应用
#include #include #include #include using namespace std;void recursive_max_heap_shift_down(int *array,int start,int end);void make_max_heap(int *array,int start,int end);void nonrecursive_make原创 2014-05-02 16:31:55 · 796 阅读 · 0 评论 -
编程之美3.3——计算字符串的相似度
问题:1. 计算两个字符串的最长公共子序列(LCS),且公共子序列在字符串中不需要是连续的。2. 计算两个字符串的距离,完全相同的字符串距离为0,可以通过修改一个字符、增加一个字符或删除一个字符三种方式来使两个字符串相同,但这些方式会使得距离加1。1.解法:这两个问题的解法基本相同,都是二维的动态规划,都考虑字符串的后缀(实际上用动态规划更喜欢考虑前缀,但使用前缀时数组最好转载 2014-05-03 11:11:10 · 525 阅读 · 0 评论 -
编程之美-先序中序 重建二叉树
#include #include #include "vld.h"using namespace std;struct Node{ Node *left; Node *right; char val; Node(char ch) { left = NULL; right = NULL; val = ch; }};void pre_order(Node原创 2014-05-03 22:59:36 · 612 阅读 · 0 评论 -
高效安排见面会
第一题为图着色问题,参见:原创 2014-04-11 22:32:37 · 620 阅读 · 0 评论 -
编程之美 -- 寻找发帖水王,以及扩展题
#include #include using namespace std;unsigned int find_id(unsigned int *array,unsigned int n);unsigned int find_half_id(unsigned int *array,unsigned int n);void find_3_more(unsigned int *array,原创 2014-04-26 17:25:33 · 808 阅读 · 0 评论 -
编程之美--求二叉树中节点的最大距离
#include #include "vld.h"using namespace std;struct Node{ char val; int max_right; int max_left; Node *right; Node *left; Node(int ch) { val = ch; max_left = 0; max_right = 0; righ原创 2014-04-28 21:24:13 · 519 阅读 · 0 评论 -
电话号码转对于英文单词 --编程之美 (递归与非递归版)
此题来着编程之美//以下用#include #include using namespace std;char num_str[10][5] ={ "", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};char * num_to_str(char *num,char *r原创 2014-06-15 10:58:11 · 1416 阅读 · 0 评论