size

操作系统之实验四主存空间的分配和回收

早过忘川 提交于 2020-02-29 10:17:02
实验四 主存空间的分配和回收 专业:商业软件工程 班级:商软2班 姓名:甘佳萍 学号:201406114207 一. 目的和要求 1.1. 实验目的 用高级语言完成一个主存空间的分配和回收程序,以加深对动态分区分配方式及其算法的理解。 1.2. 实验要求 采用连续分配方式之动态分区分配存储管理,使用首次适应算法、循环首次适应算法、最佳适应算法和最坏适应算法4种算法完成设计。 (1)**设计一个作业申请队列以及作业完成后的释放顺序,实现主存的分配和回收。采用分区说明表进行。 (2)或在程序运行过程,由用户指定申请与释放。 (3)设计一个空闲区说明表,以保存某时刻主存空间占用情况。 把空闲区说明表的变化情况以及各作业的申请、释放情况显示。 二. 实验内容 第一步: 完成程序数据结构的创建,初始化内存分配情况,创建空闲分区表和已分配分区表。 第二步: 完成为某作业分配内存空间。 用户输入作业名称; 判断作业名称是否已经存在,如果存在则要求用户重新输入; 用户输入作业所占空间大小; 判断是否能够在剩余的空闲区域中找到一块放置该作业,如果不行则要求用户重新输入; 显示菜单,由用户选择使用哪一种分配算法: 1) 首次适应算法 2) 循环首次适应算法 3) 最佳适应算法 4) 最坏适应算法 6.为该作业分配内存空间,分配处理流程图如下(size的值设定为1K) 7.屏幕显示分配后的内存分区情况。

Preconditions优雅的检验参数

拜拜、爱过 提交于 2020-02-28 13:50:50
在日常开发中,我们经常会对方法的输入参数做一些数据格式上的验证,以便保证方法能够按照正常流程执行下去。对于可预知的一些数据上的错误,我们一定要做事前检测和判断,来避免程序流程出错,而不是完全通过错误处理来保证流程正确执行,毕竟错误处理是比较消耗资源的方式。在平常情况下我们对参数的判断都需要自己来逐个写方法判断,代码量不少并且复用性不高,如下所示: import org.junit.Test;public class PreconditionsTest { @Test public void Preconditions() throws Exception { getPerson(8,"peida"); getPerson(-9,"peida"); getPerson(8,""); getPerson(8,null); } public static void getPerson(int age,String neme)throws Exception{ if(age>0&&neme!=null&&neme.isEmpty()!=true){ System.out.println("a person age:"+age+",neme:"+neme); }else{ System.out.println("参数输入有误!"); } } }   说明:参数验证

MyArrayList

大城市里の小女人 提交于 2020-02-28 11:16:09
自定义ArrayList,知多点: 1.定义字段和属性区别。 2.const、static、readonly用法。 3.索引器的定义。 4.虚方法应用。 class MyArrayList { //容量 private const int _defaultCapacity = 4; //存放数组元素 private object[] _items; //数组大小 private int _size; //元素个数为0的数组状态 private static readonly object[] emptyArray = new object[0]; public MyArrayList() { this._items = emptyArray; } public MyArrayList( int capacity) { if (capacity<0) { throw new ArgumentOutOfRangeException("capacity","ArrayList的容量不可为负数!"); } this._items = new object[capacity]; } //索引器 public virtual object this[int index] { get { if (index<0||index>=this._size) { throw new

如何使用PIL调整图像大小并保持其纵横比?

时光怂恿深爱的人放手 提交于 2020-02-27 03:32:33
是否有一种显而易见的方法可以解决这个问题? 我只是想制作缩略图。 #1楼 PIL已经可以选择裁剪图像 img = ImageOps.fit(img, size, Image.ANTIALIAS) #2楼 我丑陋的例子。 函数获取文件如:“pic [0-9a-z]。[extension]”,将它们调整为120x120,将部分移动到中心并保存到“ico [0-9a-z]。[extension]”,使用纵向和景观: def imageResize(filepath): from PIL import Image file_dir=os.path.split(filepath) img = Image.open(filepath) if img.size[0] > img.size[1]: aspect = img.size[1]/120 new_size = (img.size[0]/aspect, 120) else: aspect = img.size[0]/120 new_size = (120, img.size[1]/aspect) img.resize(new_size).save(file_dir[0]+'/ico'+file_dir[1][3:]) img = Image.open(file_dir[0]+'/ico'+file_dir[1][3:]) if img

C++中vector使用问题01_size-1无限循环

老子叫甜甜 提交于 2020-02-26 11:58:17
1 问题 在对一个vector进行循环处理时,例如排序,会经常这么写: for (size_t i = 0; i < vec.size() - 1; i++) { for (size_t j = i + 1; j < vec.size(); j++) { // do something } } 这里会出现无限循环。 2 分析 如果vec的元素数量为0,那么size_t类型的 i=0-1 ,在计算里就变成了最大值,所以导致出现进入死循环的情况。 切记,不要犯这种低级错误。 3 解决办法 去掉减1即可。或者加个判断。 for ( size_t i = 0 ; i < vec.size ( ) ; i++ ) { for ( size_t j = i + 1 ; j < vec.size ( ) ; j++ ) { // do something } } 来源: CSDN 作者: 张欣-男 链接: https://blog.csdn.net/sdlypyzq/article/details/104512276

ios开发常用宏

ⅰ亾dé卋堺 提交于 2020-02-26 10:53:19
本文整理自: http://blog.csdn.net/duxinfeng2010/article/details/9067947 http://hi.baidu.com/feng20068123/item/1935c6d022bf7513d78ed0d4 根据自己的习惯做了一些修改,简化。 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 #ifndef

iOS常用宏定义

回眸只為那壹抹淺笑 提交于 2020-02-26 10:08:41
/*--> */ /*--> */ #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/ 255.0 green:(g)/ 255.0 blue:(b)/ 255.0 alpha: 1 ] #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/ 255.0 green:(g)/ 255.0 blue:(b)/ 255.0 alpha:(a)] #define SCREEN [[UIScreen mainScreen] bounds] #define kSpaceX 50 #define Helvetica @ "Helvetica Neue" #define HelveticaBold @ "Helvetica-Bold" #define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0 ] #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/ 255.0 green:(g)/ 255.0 blue:(b)/ 255.0 alpha: 1 ] #define

2020 CCPC Wannafly Winter Camp Day1 F

孤人 提交于 2020-02-25 22:13:19
2020 CCPC Wannafly Winter Camp Day1 F 文章目录 2020 CCPC Wannafly Winter Camp Day1 F 题目 思路 代码 题目 思路 假定这个答案是ANS,那我们就二分ANS,然后对于每一个 A i A_i A i ​ ,二分寻找对应的 B j B_j B j ​ ,使得 A i ∗ B j < A N S A_i * B_j \lt ANS A i ​ ∗ B j ​ < A N S ,然后统计个数,如果这个数不是K,那么就调整ANS的值就好了,注意讨论负数和0 代码 题解代码 # include <iostream> # include <cmath> # include <cstring> # include <cstdio> # include <algorithm> # include <cassert> # include <map> # include <vector> using namespace std ; int n , m ; long long K ; const int N = 110000 ; vector < int > A [ 3 ] , B [ 3 ] ; long long get ( long long lim ) { if ( lim >= 0 ) { long long ans =

font size change after orientation screen change to horizontal

99封情书 提交于 2020-02-25 05:41:47
问题 i have build application web on iphone, but the font size is change it to large when i rotate my iphone.. anybody know how to keep size the font? thank you.. 回答1: I have found the answer.. To ignore the change of font size on rotation, simply add -webkit-text-size-adjust: none; 来源: https://stackoverflow.com/questions/4616019/font-size-change-after-orientation-screen-change-to-horizontal

font size change after orientation screen change to horizontal

梦想的初衷 提交于 2020-02-25 05:41:30
问题 i have build application web on iphone, but the font size is change it to large when i rotate my iphone.. anybody know how to keep size the font? thank you.. 回答1: I have found the answer.. To ignore the change of font size on rotation, simply add -webkit-text-size-adjust: none; 来源: https://stackoverflow.com/questions/4616019/font-size-change-after-orientation-screen-change-to-horizontal