算法
文章平均质量分 61
hello556
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
EXP
//输入:实数x和非负整数n //输出:x的n次方 #include using namespace std; double myexp(double x,unsigned int n) { double result = 1; while (n > 0) { if(n&1 == 1) result *= x; x *= x; n >>= 1; //逻辑右移 }原创 2014-09-01 21:01:08 · 436 阅读 · 0 评论 -
寻找多数元素(Majority)
//寻找数组中的多数元素(元素个数大于数组的一半) #include using namespace std; void majority(int *A,int n) { int current = A[0]; int count = 1; for (int i = 0;i < n;i++) { if (count == 0) { current = A[i];原创 2014-09-02 17:02:38 · 987 阅读 · 0 评论 -
排序算法-基数排序(RadixSort)
#include #include using namespace std; int pow10(int n) { int result = 10; if (n==0) { return 1; } for (int i = 0;i < n;i++) { result *= 10; } return result; } void radixSort(int *L,原创 2014-09-01 20:37:08 · 542 阅读 · 0 评论 -
最长公共子序列(Python)
参考:手写代码必备手册def lcs(x,y): d = [0] * (len(x) + 1) for i in range(0,len(d)): d[i] = [0] * (len(y) + 1) for i in range(1,len(x) + 1): for j in range(1, len(y) + 1): if x[i-1] == y[j-1]: d[i][j] = d[i-1][j原创 2016-04-08 16:13:34 · 1529 阅读 · 0 评论
分享