算法
文章平均质量分 68
topgun_topgun
这个作者很懒,什么都没留下…
展开
-
模板数组,下标检查
#include iostream>using namespace std;template class T> class Array;template class T> class ArrayBody...{ friend class ArrayT>; T* tpBody; int iRows, iColumn, iCurrentRow; ArrayBody(int原创 2007-06-20 21:51:00 · 775 阅读 · 0 评论 -
筛选法求素数
#include iostream> #include cmath> using namespace std; int main(int ac, char** av) ...{ const MAX = 100; bool sieve[MAX + 1]; fill(sieve, sieve + MAX + 1, t原创 2007-06-20 09:49:00 · 527 阅读 · 0 评论 -
“背包问题”的算法
问题基本描述:有一个背包,能盛放的物品总重量为S,设有N件物品,其重量分别为w1,w2,...wn,希望从N件物品中选择若干件物品,所选物品的重量之和恰能放入该背包,即所选物品的重量之和等于S。递归算法 #include stdio.h>#define N 7#define S 15int w[N+1] = ...{0,1,2,3,4,5,6,7};int knap(int s,原创 2007-06-20 22:02:00 · 5270 阅读 · 0 评论