2018年11月4日

摘要: #include #include #include typedef struct HuffmanTree { int weight; int parent, lchild, rchild; }HuffmanTree; typedef struct CodeNode { int ch; char bits[4+1]; }CodeNode; ... 阅读全文
posted @ 2018-11-04 21:39 梓离 阅读(219) 评论(0) 推荐(0)
摘要: /*0-1背包伪代码*/ #include using namespace std; template class Knap //Knap类记录解空间树的结点信息 { template friend Typep Knapsack(Typep [],Typew [],Typew,int); //负责对变量初始化,调用递归... 阅读全文
posted @ 2018-11-04 21:26 梓离 阅读(2682) 评论(0) 推荐(0)
摘要: /*0-1背包回溯法实现*/ #include #include int n; //物品数量 double c; //背包容量 double v[100]; //各个物品的价值 double w[100]; //各个物品的重量 double cw = 0.0; //当前背包重量 double cp = 0.0; //当前背包中物品价值 double bestp = 0.0;... 阅读全文
posted @ 2018-11-04 21:23 梓离 阅读(238) 评论(0) 推荐(0)
摘要: /*0-1背包问题*/ #include int V[200][200]; //前i个物品装入容量为j的背包中获得的最大价值 int max(int a,int b) { if(a>=b) return a; else return b; } int KnapSack(int n,int w[],int v[],int x[],in... 阅读全文
posted @ 2018-11-04 21:18 梓离 阅读(151) 评论(0) 推荐(0)

2018年11月3日

摘要: // sun.cpp : 定义控制台应用程序的入口点。 //本算法包含四种调度:先到先服务,短作业优先,时间片轮转,优先级调度 #include #define N 50 void main() { void fcfs(); //先来先服务 void sjf(); //短作业优先 void rr(); //时间片轮转 void yxj(); //优先级调度 i... 阅读全文
posted @ 2018-11-03 13:48 梓离 阅读(338) 评论(0) 推荐(0)
摘要: #include #include #include #include #define maxsize 1000 /*********************判断输入数据是否有效**************************/ int decide(char str[]) //判断输入数据是否有效 { int i=0; while(str[i]!='\0') { i... 阅读全文
posted @ 2018-11-03 13:44 梓离 阅读(188) 评论(0) 推荐(0)
摘要: #include #include #include void Print(int bc[],int blockCount) { int i; for(i=0;i=k) { k=a[i]; j=i; } } return j; } void LRU(int pc[],int bc[],int pageCount,int blockCount)... 阅读全文
posted @ 2018-11-03 13:39 梓离 阅读(215) 评论(0) 推荐(0)
摘要: #include #include /*全局变量*/ int mSIZE; //物理块数 int pSIZE; //页面号引用串个数 static int memery[10]={0}; //物理块中的页号 static int page[100]={0}; //页面号引用串 static int temp[100][10]={0}; //辅助数组 /*置换算法函数*... 阅读全文
posted @ 2018-11-03 13:36 梓离 阅读(398) 评论(0) 推荐(0)
摘要: #include ////////////////////////////////////////////////////////////////////////// //全局变量定义 int Available[100]; //可利用资源数组 int Max[50][100]; //最大需求矩阵 int Allocation[50][100]; //分配矩阵 int Need[50][... 阅读全文
posted @ 2018-11-03 13:33 梓离 阅读(346) 评论(0) 推荐(0)
摘要: #include int curr[5][5], maxclaim[5][5], avl[5]; int alloc[5] = {0, 0, 0, 0, 0};//已分配的资源 int maxres[5], running[5], safe=0; int count = 0, i, j, exec, r, p, k = 1; void main() { printf("\n请输入进程... 阅读全文
posted @ 2018-11-03 13:31 梓离 阅读(617) 评论(0) 推荐(0)

导航