技术改变命运
发布时间:2016-07-06 10:22:57
题目描述:? ? 输入两个整数n和sum,要求从数列1,2,3...n中随意取出几个数,使得他们的和等于sum,请将其中所用可能的组合列出来。思路:n问题转化成n-1问题? ? 考虑是否取第n个数的策略,问题可以转换为一个只与前n-1个数相关的问题,注意取n与不取n的区别。c++代码如下点击(此处)折叠或.........【阅读全文】
发布时间:2016-07-05 17:42:47
You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree-it does not have to start at the root.思路:一层一层的遍历,保存当前节点到根节点的完整路径,然后从当前节点向上扫描,如果找到.........【阅读全文】
发布时间:2016-07-04 21:12:44
树的一些基本操作(遍历,构造,高度,节点数,销毁)c语言代码如下:点击(此处)折叠或打开#include<stdio.h>#include<stdlib.h>#include<unistd.h>struct BinaryTree{ struct BinaryTree *pLeft,*.........【阅读全文】