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
std::swap()是个很有用的函数,它可以用来交换两个变量的值,包括用户自定义的类型,只要类型支持copying操作,尤其是在STL中使用的很多,例如:int
main(int argc, _TCHAR* argv[]) { int a[10] = {1,2,3,4,5,6,7,8,...
分类:
编程语言 时间:
2014-05-19 15:22:41
阅读次数:
378
#includeusing namespace std;//大根堆,从小到达排序int
a[101];void swap(int &a,int &b){ a=a^b; b=a^b; a=a^b; }void adjust(int
*a,int root,int len){ int max=root;...
分类:
其他好文 时间:
2014-05-19 15:13:43
阅读次数:
219
1 #include 2 #include 3 using namespace std; 4 5
void modifyArray(int [], int); 6 void modifyElement(int); 7 8 int main() 9 {10
const int arr...
分类:
其他好文 时间:
2014-05-19 15:12:27
阅读次数:
257
>_____ 2 #include "TicTac.h" 3 #include 4
#include 5 #include 6 using namespace std; 7 CMyApp myApp; 8 /*ofstream
Cout("out.txt"); 9 void CM...
分类:
其他好文 时间:
2014-05-19 14:34:51
阅读次数:
430
#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