算法实验
文章平均质量分 67
mll1208596630
这个作者很懒,什么都没留下…
展开
-
Treap堆的插入,删除操作
#include #include #include #include #include using namespace std; typedef struct node { node* left; node* right; int priority; int key; }*Node; typedef struct treap { Node root; }*Treap原创 2015-12-19 13:59:24 · 482 阅读 · 0 评论 -
任务调度问题
//#include #include #include #include using namespace std; void swapw(int &x, int &y) { int temp; temp = x; x = y; y = temp; } void task(int *d, int *w, int n) { int i,j; int *a原创 2015-12-19 14:04:28 · 509 阅读 · 0 评论 -
快速排序
#include #include using namespace std; void quicksort(int a[],int low,int high,int i1,char c) { if(low>=high) return; int i=low; int j=high; int key=a[i]; while(i<j) { while(i=key) --j原创 2015-12-19 14:18:47 · 246 阅读 · 0 评论 -
C++ 动态规划0-1背包问题
#include using namespace std; void compute(int volume,int n,int w[],int p[],int value[][100]) { for(int j=0;j<=volume;j++) if(j>=w[0]) value[0][j]=p[0]; else value[0][j]=0; for( int i=1;原创 2015-12-19 14:25:12 · 535 阅读 · 0 评论 -
C++ 红黑树增加、删除等操作
#include #include using namespace std; class RBNode{ public: int color; //0为红色,1为黑色 int key; RBNode *left; RBNode *right; RBNode *p原创 2015-12-19 14:39:21 · 695 阅读 · 0 评论 -
C++ 贪心算法部分背包问题
#include using namespace std; void swap(float ave[],int s[],int n) { int i,j; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(ave[s[i]]<=ave[s[j]]) { int temp=s[i]; s[i]=s[j]; s[j]=temp原创 2015-12-19 14:32:41 · 3524 阅读 · 0 评论