算法
文章平均质量分 68
Jack_Lpz
Jack_Li style
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
汗诺塔问题
#include using namespace std;void hanoi(int n, char a, char b, char c){ if(1 == n) //the last step: from a to c { cout " } else { hanoi(n-1, a, c, b); //use b as a原创 2014-09-05 20:31:24 · 1382 阅读 · 0 评论 -
菲波那契数列
#include using namespace std;int fab(int n){ int *arr = new int[n]; arr[0] = 1; arr[1] = 2; int result = 0; for(int i=2; i arr[i]= arr[i-1] + arr[i-2];原创 2014-09-06 23:16:18 · 513 阅读 · 0 评论 -
各类排序算法(已包装好)
以下是各类排序算法(本人在VS2008下已经验证),还有一些不足(例如模板化)思想比代码本身重要.....呵呵sort.h #ifndef SORT_H#define SORT_Hconst int maxNum = 100;class Diff_Sort{public:Diff_Sort(); virtual void原创 2014-09-06 22:15:37 · 624 阅读 · 0 评论 -
两个数据交换的几种方式
#include "stdafx.h"#include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ int a = 2; int b = 3; /* 方法1:利用中间变量 temp int temp = a; a = b; b = temp; */ /* 方法原创 2014-09-06 22:17:05 · 705 阅读 · 0 评论 -
杨辉三角
#include #include using namespace std;//#include const int N = 6;//use position and computer it's numberlong computer(int n, int r){ long p = 1; for(int i=1; i p = p原创 2014-09-08 23:05:06 · 490 阅读 · 0 评论 -
八个硬币中找假
#include using namespace std;#include //用于随机产生的硬币重量#include const int N = 8;int calCoin(int *arr);int main(){ int* arr = new int[N]; for(int i=0; i { arr原创 2014-09-21 12:00:02 · 798 阅读 · 0 评论 -
三色棋
#include #include using namespace std;void swap(char &x, char &y){ char temp = y; y = x; x = temp;}int main(){ char color[] = {'r', 'w', 'b', 'w', 'w', 'b', 'r',原创 2014-09-09 19:40:58 · 1082 阅读 · 0 评论 -
字符串的查找算法
//包括BF算法 KMP算法 Hash算法#include "stdafx.h"#include #include using namespace std;static int find(char S[],char T[], int pos){ int i = pos; int j = 0; int sLen = strlen(S); int tLen =原创 2014-09-12 23:15:57 · 677 阅读 · 0 评论 -
x的n次方求解 与 优化
#include "stdafx.h"#include using namespace std;int power(int x, int n) //注意数值不要大 整数表示范围有限{ int y=x; while(n>1) { y *= x; n--; } return y;}int fastPower(int x, int n)原创 2014-09-12 23:18:53 · 2385 阅读 · 0 评论
分享