上一页 1 ··· 46 47 48 49 50 51 52 53 54 ··· 99 下一页

2011年7月29日

线性筛素数

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>const int N = 10000000;bool a[N];int p[N];using namespace std;void debug( ){ #ifdef P freopen("out","w",stdout); #endif } void prime( ){ debug( ); memset(a, 0, N*sizeof(a[0])); int nu 阅读全文

posted @ 2011-07-29 20:58 more think, more gains 阅读(143) 评论(0) 推荐(0) 编辑

copy

摘要: #include <stdio.h>#include <iostream>#include <algorithm>#include <vector>using namespace std;int main( ){ int my[]={10,32,324,43,43,2332,3223}; vector<int>myvector; vector<int>::iterator it; myvector.resize(7); copy(my, my + 7, myvector.begin()); for( it = myvect 阅读全文

posted @ 2011-07-29 20:21 more think, more gains 阅读(90) 评论(0) 推荐(0) 编辑

min heap

摘要: // range heap example#include <iostream>#include <algorithm>#include <vector>#include <functional>using namespace std;bool cmp( int x, int y){ return x > y;}int main () { int myints[] = {10,20,30,5,15}; vector<int> v(myints,myints+5); vector<int>::iterator it; 阅读全文

posted @ 2011-07-29 16:29 more think, more gains 阅读(194) 评论(0) 推荐(0) 编辑

heap stl 各类操作 http://www.cplusplus.com/reference/algorithm/push_heap/

摘要: // range heap example#include <iostream>#include <algorithm>#include <vector>using namespace std;int main () { int myints[] = {10,20,30,5,15}; vector<int> v(myints,myints+5); vector<int>::iterator it; make_heap (v.begin(),v.end()); cout << "initial max heap : 阅读全文

posted @ 2011-07-29 16:14 more think, more gains 阅读(203) 评论(0) 推荐(0) 编辑

heap 堆的各类操作

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>int N;//最小堆int heap[20];//交换两个元素的值void swap( int &x, int &y){ int temp; temp = x; x = y; y = temp;}// 非递归写法void down ( int x ){ int i, j, flag = 1; if ( 2 * x <= N) { while (flag && (i = 2 * x) <= N ) { i 阅读全文

posted @ 2011-07-29 15:56 more think, more gains 阅读(231) 评论(0) 推荐(0) 编辑

上一页 1 ··· 46 47 48 49 50 51 52 53 54 ··· 99 下一页

导航