- 博客(7)
- 资源 (1)
- 收藏
- 关注
原创 递归算法——全排列
#include #include using namespace std;int n = 0;ofstream fout("perm.txt");void swap(int *a, int *b){ int tmp = *a; *a = *b; *b = tmp;}bool contains(int list[], int k, int i){ for (int
2013-12-19 19:18:20 519
原创 鸽巢原理
鸽巢原理:如果鸽子数比鸽巢数多,那么一定有一个鸽巢里至少有两只鸽子定理1:k+1或更多个物体放入k个盒子,一定至少有一个盒子有2个或更多的物体应用1:对每个整数n,存在一个数是n的倍数,且它的十进制表示只包含0和1证:n+1个数,1,11,111,...,111……111(n+1个1)。这些数被n整除,得到n+1个余数,由于,一个数整除n只能得到0~n-1的n个数,所以
2013-12-19 18:59:47 870
原创 递归算法——Hannoi
#include #include using namespace std;ofstream fout("hannoi.txt");void Move(int n, char i, char j){ fout << "put the " << n << "th from " << i << " to " << j << endl;}void Hannoi(int n,
2013-05-19 00:10:04 737
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人