1、 递归算法:quicksort.cpp#include using namespace
std;void Swap(int a[],int i,int j){ int temp=a[i]; a[i] = a[j]; a[j] = temp;}int
Partition(int a[],int l...
分类:
其他好文 时间:
2014-05-27 02:29:55
阅读次数:
274
源码://HeapSort.cpp#include using namespace
std;//about heap://the last leaf node is a[n-1]//the last non-leaf node is
a[n/2-1];// a[i]// ...
分类:
其他好文 时间:
2014-05-27 02:21:23
阅读次数:
240
算法源码://BubbleSort.cpp#include using namespace
std;void BubbleSort(int a[], int n){ for(int i=n-1;i>0;i--) { for(int
j=0;ja[j+1]) { int tmp = a[j...
分类:
其他好文 时间:
2014-05-27 02:07:07
阅读次数:
223
题意:对于n,m,k,定义n的操作,+m,-m,*m,%m,(You should know that
if a = b * q + r (q > 0 and 0 3 #include 4 #include 5 #include 6 #include 7
using namespace s...
分类:
其他好文 时间:
2014-05-27 01:39:48
阅读次数:
285
最近看数据结构时看到直接插入排序法,其基本思想是:将一个记录插入到已经排好序的有序表中,从而得到一个新的,记录数增1的有序表下面是代码实现与测试 1
#include 2 using namespace std; 3 void InsertSort(int *q,int L) 4 { 5 ...
分类:
其他好文 时间:
2014-05-24 07:07:19
阅读次数:
285
#includeusing namespace std;int main(){ int s1 = 1;
unsigned int s2 = 1; cout>和逻辑右移(不带符号)>>>。 //算术右移:符号位不变,左边补上符号位。如:
1000 1000 >> 3 为 1111 0001 //逻辑右...
分类:
其他好文 时间:
2014-05-24 06:45:46
阅读次数:
280
#include#include#includeusing namespace std;const
int N = 10;int helper(int* a,const int num1,const int num2){ int i=1; int j=1;
for(int m = 0;m te...
分类:
其他好文 时间:
2014-05-24 06:17:01
阅读次数:
222
#include#includeusing namespace std;int
helper(const int a[],const int n){ map m; for(int i = 0;i::iterator comp =
m.begin(); for( map::iterator it...
分类:
其他好文 时间:
2014-05-19 12:44:34
阅读次数:
270
#include#include#includeusing namespace std;int
helper1(int a[],int n){ int sum = accumulate(a,a+n,0); int sum2 = n*(n-1)/2;
return sum-sum2;}int h...
分类:
其他好文 时间:
2014-05-19 12:25:25
阅读次数:
183
#includeusing namespace std;bool solver(const int
a[],const int n, int & num){ if(NULL == a || 0>= n) return false;
////注意,是小写~ int count = 0; ...
分类:
其他好文 时间:
2014-05-19 12:11:20
阅读次数:
335