- 博客(11)
- 收藏
- 关注
原创 电梯调度算法
假设要求从系统中输入N个需访问的柱面号,当前磁头的移动方向由键盘输入(1代表磁头从外往内移动,-1代表磁头由内往外移动),当前磁头刚完成访问序号为M的柱面,请编程输出采用电梯调度算法得到的柱面访问序列号,同时输出读/写磁头总共移动的距离(用柱面数表示)#include<cstdio>#include<algorithm>using namespace std;const int maxn = 1e5 + 5;int t[maxn];int pre, now, dir
2021-12-25 23:33:44 515
原创 优先调度算法
优先数调度算法来模拟实现处理器调度过程。//利用C/C++模拟进程调度,运用优先调度算法#include<stdio.h>#include<stdlib.h>#include<algorithm>using namespace std;enum process_status{READY, RUN, FINISH}; //进程的三种状态typedef struct pcb //定义进程数据结构{ struct
2021-12-25 23:32:47 603
原创 请求分页式存储管理的页面置换
在分页式虚拟存储管理中,要求通过键盘输入分配给一个作业的物理块数和作业依次访问的10个页面号,采用先进先出(FIFO)页面置换后,顺序输出缺页中断时所淘汰的页面号,并计算缺页中断率。#include<cstdio>using namespace std;const int maxn = 1e5 + 5;int page_now;int page_num, space_num;int flag[maxn], space_array[maxn];int main(){
2021-12-25 23:31:49 926
原创 响应比高优先调度算法
#include<cstdio>#include<algorithm>using namespace std;const int maxn = 1e4 + 5;int flag[maxn];struct{ char name[maxn]; int arrive, time_sum;}JOB1[maxn];struct{ char name[maxn]; int arrive, time_sum, start_time, en
2021-12-25 23:30:32 736
原创 可变分区存储管理的空间分配与去配
#include <stdio.h>#include <stdlib.h>#include <string.h>#define JOB_MAX 10struct{ int id, length, address;}used_table[JOB_MAX];struct f_table{ int length, address;}free_table[JOB_MAX + 1];int free_num = 1;int used_n
2021-12-25 23:29:27 593
原创 银行家算法
#include<cstdio>using namespace std;#define true 1#define false 0#define MAXINT 9999//typedef int bool;bool Finish[100];int request[100];int processNum = 5;int resourceNum = 3;int available[100] = {3, 3, 2};int safeSeries[100] = {MAXIN
2021-12-25 23:28:00 285
原创 二分法 平均数
洛谷P1404题目要求寻找一个序列的长度大于m的子串的平均数最大值二分法求平均数#include<cstdio>#include<math.h>#include<algorithm>using namespace std;const double ep = 1e-7;const int maxn = 1e5 + 5;int maxx;double ans;void scan(int a[maxn], int n){ int i;
2021-07-29 13:48:12 246
原创 高精度加法
洛谷P1601#include<cstdio>#include<iostream>#include<string.h>#include<math.h>#include<algorithm>using namespace std;void bigint(){ char a[105], b[105], c[105]; memset(c, 0, sizeof(c)); int n, m, i, j, s;
2021-07-28 17:33:03 50
原创 线段树 区间加
线段树为二叉搜索树,下面代码实现区间和的查询和个体元素的修改。#include<cstdio>#include<iostream>#include<algorithm>using namespace std;const int maxx = 1e6;int a[maxx], tree[maxx * 10];void build_tree(int l, int r, int s){ int mid, s1, s2; mid = (l
2021-07-10 09:35:42 126
原创 欧拉筛法。
欧拉筛 时间复杂度O(n)#include<cstdio>#include<iostream>using namespace std;#define maxx 1e6int t; //记录素数个数int p[maxx]; //记录素数int v[maxx]; //v[i]的值表示i是否为素数void linear_screening(int e){ int i, j; t = 0; v[0] = 1; v[1] = 1; for(i
2021-07-09 20:50:39 75
原创 大正整数除以小正整数,求商与余数(C语言)
模拟除法竖式方法进行运算#include<stdio.h>#include<stdlib.h>#include<string.h>int n;char ans[100005]; //ans记录商char a[100005], b[100005];int main(){ int i = 0, j = 0; int p = 0, q = 0, k; //p为余数 scanf("%s %d", a, &q)
2020-12-04 19:44:52 659
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人