#include #include using namespace std;int dp[105][1005], w[105],v[105],T,M,;int max(int x,int y) { return x>y?x:y; }int f(int x,int y){ int t; if (...
分类:
其他好文 时间:
2014-08-12 21:48:24
阅读次数:
289
一. 二叉树定义:二叉树具有天然的递归特性,凡是二叉树相关题,首先应该联想到递归struct BinTreeNode { BinTreeNode* left; BinTreeNode* right; int val; BinTreeNode(int valu...
分类:
其他好文 时间:
2014-08-12 21:45:24
阅读次数:
314
#include using namespace std;int dp[105][1005],w[105],v[105] ;int max(int a,int b) { return a > b ? a : b; }int f(int x,int y){ int t ; if(dp[x][...
分类:
其他好文 时间:
2014-08-12 21:36:24
阅读次数:
295
#include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N],ans,len1,len2;int max(int a,int b){ return a>b ? a : b ; }int f(in....
分类:
其他好文 时间:
2014-08-12 21:29:24
阅读次数:
175
// 0-1背包问题的普通递归算法#include #define M 10int w[M]={5,3,2,1},v[M]={4,4,3,1};int limit_w=7,maxv=0,n=4; void find(int i,int tw,int tv) //从第i种物品开始,当前已有的...
分类:
其他好文 时间:
2014-08-12 21:24:54
阅读次数:
173
本文是学习网络上的文章时的总结,感谢大家无私的分享。
1、如果线程实现的是由复杂算法分成的一些方法,或者他的方法有递归调用,那么我们可以用更好的机制来控制线程中断。为了这个Java提供了InterruptedException异常。当你检测到程序的中断并在run()方法内捕获,你可以抛这个异常。
2、InterruptedException异常是由一些与并发API相关的Java方法,如sl...
分类:
编程语言 时间:
2014-08-12 19:08:24
阅读次数:
281
//快速排序思想:选择数组最后一个数(key),比它小的排他前面 ( key放中间 ) 比它大的排后面,
然后递归 终止条件(数组只有一个数)
public class Sort> { //能排序的都是能比较的,所以必须继承java.lang.Comparable
public void quick(T[] array){
sort(array,0,array.length...
分类:
编程语言 时间:
2014-08-12 18:59:34
阅读次数:
181
#include int fib(int n){ if (n<=1) return 1; else return fib(n-1)+fib(n-2); }int main( ){ int n; scanf("%d",&n); printf("%d\n" ,fib( ...
分类:
其他好文 时间:
2014-08-12 18:37:44
阅读次数:
169
#include #include#includeusing namespace std;char a[10002];int b[10002];int n,ans;int f(int x){ int i,t; for(i=0;i>n;for(i=1;i#include#includeusing n....
分类:
其他好文 时间:
2014-08-12 18:31:24
阅读次数:
294
字典序全排列算法研究一.非递归算法(字典序法)对给定的字符集中的字符规定了一个先后关系,在此基础上规定两个全排列的先后是从左到右逐个比较对应的字符的先后。例如:字符集{1,2,3},较小的数字位置较先,这样按字典序生成的全排列是 123,132,213,231,312,321※ 一个全排列可看做一个...
分类:
其他好文 时间:
2014-08-12 18:20:14
阅读次数:
277