操作系统课的实验(银里手算法)#include"malloc.h"  #include"stdio.h"  #include"stdlib.h"  #definealloclensizeof(structallocation)  #definemaxlensizeof(structmax)  #defineavalensizeof(structavailable)  #defineneedlensizeof(structneed)  #definefinilensizeof(structfinish)  #definepathlensizeof(structpath)  structallocation  {  intvalue;  structallocation*next;  };  structmax  {  intvalue;  structmax*next;  };  structavailable/*可用资源数*/  {  intvalue;  structavailable*next;  };  structneed/*需求资源数*/  {  intvalue;  structneed*next;  };  structpath  {  intvalue;  structpath*next;  };  structfinish  {  intstat;  structfinish*next;  };  intmain()  {  introw,colum,status=0,i,j,t,temp,processtest;  structallocation*allochead,*alloc1,*alloc2,*alloctemp;  structmax*maxhead,*maxium1,*maxium2,*maxtemp;  structavailable*avahead,*available1,*available2,*workhead,*work1,*work2,*worktemp,*worktemp1;  structneed*needhead,*need1,*need2,*needtemp;  structfinish*finihead,*finish1,*finish2,*finishtemp;  structpath*pathhead,*path1,*path2;  printf("\n请输入系统资源的种类数:");  scanf("%d",&colum);  printf("请输入现时内存中的进程数:");  scanf("%d",&row);  printf("请输入已分配资源矩阵:\n");  for(i=0;inext=alloc2->next=NULL;  scanf("%d",&allochead->value);  status++;  }  else  {  alloc2=(structallocation*)malloc(alloclen);  scanf("%d,%d",&alloc2->value);  if(status==1)  {  allochead->next=alloc2;  status++;  }  alloc1->next=alloc2;  alloc1=alloc2;  }  }  }  alloc2->next=NULL;  status=0;  printf("请输入最大需求矩阵:\n");  for(i=0;inext=maxium2->next=NULL;  scanf("%d",&maxium1->value);  status++;  }  else  {  maxium2=(structmax*)malloc(maxlen);  scanf("%d,%d",&maxium2->value);  if(status==1)  {  maxhead->next=maxium2;  status++;  }  maxium1->next=maxium2;  maxium1=maxium2;  }  }  }  maxium2->next=NULL;  status=0;  printf("请输入现时系统剩余的资源矩阵:\n");  for(j=0;jnext=available2->next=NULL;  work1->next=work2->next=NULL;  scanf("%d",&available1->value);  work1->value=available1->value;  status++;  }  else  {  available2=(structavailable*)malloc(avalen);  work2=(structavailable*)malloc(avalen);  scanf("%d,%d",&available2->value);  work2->value=available2->value;  if(status==1)  {  avahead->next=available2;  workhead->next=work2;  status++;  }  available1->next=available2;  available1=available2;  work1->next=work2;  work1=work2;  }  }  available2->next=NULL;  work2->next=NULL;  status=0;  alloctemp=allochead;  maxtemp=maxhead;  for(i=0;inext=need2->next=NULL;  need1->value=maxtemp->value-alloctemp->value;  status++;  }  else  {  need2=(structneed*)malloc(needlen);  need2->value=(maxtemp->value)-(alloctemp->value);  if(status==1)  {  needhead->next=need2;  status++;  }  need1->next=need2;  need1=need2;  }  maxtemp=maxtemp->next;  alloctemp=alloctemp->next;  }  need2->next=NULL;  status=0;  for(i=0;inext=finish2->next=NULL;  finish1->stat=0;  status++;  }  else  {  finish2=(structfinish*)malloc(finilen);  finish2->stat=0;  if(status==1)  {  finihead->next=finish2;  status++;  }  finish1->next=finish2;  finish1=finish2;  }  }  finish2->next=NULL;/*Initializationcompleated*/  status=0;  processtest=0;  for(temp=0;tempstat==0)  {  for(j=0;jnext,worktemp=worktemp->next)  if(needtemp->valuevalue)  processtest++;  if(processtest==colum)  {  for(j=0;jvalue+=alloctemp->value;  worktemp1=worktemp1->next;  alloctemp=alloctemp->next;  }  if(status==0)  {  pathhead=path1=path2=(structpath*)malloc(pathlen);  path1->next=path2->next=NULL;  path1->value=i;  status++;  }  else  {  path2=(structpath*)malloc(pathlen);  path2->value=i;  if(status==1)  {  pathhead->next=path2;  status++;  }  path1->next=path2;  path1=path2;  }  finishtemp->stat=1;  }  else  {  for(t=0;tnext;  finishtemp->stat=0;  }  }  else  for(t=0;tnext;  alloctemp=alloctemp->next;  }  processtest=0;  worktemp=workhead;  finishtemp=finishtemp->next;  }  }  path2->next=NULL;  finishtemp=finihead;  for(temp=0;tempstat==0)  {  printf("\n系统处于非安全状态!\n");  exit(0);  }  finishtemp=finishtemp->next;  }  printf("\n系统处于安全状态.\n");  printf("\n安全序列为:\n");  do  {  printf("p%d",pathhead->value);  }  while(pathhead=pathhead->next);  printf("\n");  return0;  }#include"string.h"#include#include#defineM5#defineN3#defineFALSE0#defineTRUE1/*M个进程对N类资源最大资源需求量*/intMAX[M][N]={{7,5,3},{3,2,2},{9,0,2},{2,2,2},{4,3,3}};/*系统可用资源数*/intAVAILABLE[N]={10,5,7};/*M个进程对N类资源最大资源需求量*/intALLOCATION[M][N]={{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}};/*M个进程已经得到N类资源的资源量*/intNEED[M][N]={{7,5,3},{3,2,2},{9,0,2},{2,2,2},{4,3,3}};/*M个进程还需要N类资源的资源量*/intRequest[N]={0,0,0};voidmain(){inti=0,j=0;charflag='Y';voidshowdata();voidchangdata(int);voidrstordata(int);intchkerr(int);showdata();while(flag=='Y'||flag=='y'){i=-1;while(i=M){printf("请输入需申请资源的进程号(从0到");printf("%d",M-1);printf(",否则重输入!):");scanf("%d",&i);if(i=M)printf("输入的进程号不存在,重新输入!\n");}printf("请输入进程");printf("%d",i);printf("申请的资源数\n");for(j=0;jNEED[i][j]){printf("进程");printf("%d",i);printf("申请的资源数大于进程");printf("%d",i);printf("还需要");printf("%d",j);printf("类资源的资源量!申请不合理,出错!请重新选择!\n");/*printf("申请不合理,出错!请重新选择!\n");*/flag='N';break;}else{if(Request[j]>AVAILABLE[j]){printf("进程");printf("%d",i);printf("申请的资源数大于系统可用");printf("%d",j);printf("类资源的资源量!申请不合理,出错!请重新选择!\n");/*printf("申请不合理,出错!请重新选择!\n");*/flag='N';break;}}}if(flag=='Y'||flag=='y'){changdata(i);if(chkerr(i)){rstordata(i);showdata();}elseshowdata();}elseshowdata();printf("\n");printf("是否继续银里手算法演示,按'Y'或'y'键继续,按'N'或'n'键退出演示:");scanf("%c",&flag);}}voidshowdata(){inti,j;printf("系统可用的资源数为:\n");printf("");for(j=0;j");}printf("\n");return0;}
2015/11/20 3:54:43 883KB 算法 银行家
1
CVD技能,你懂得main(){externa,b,c;putchar(a);putchar(b);putchar(c);putchar('!*n');}a'hell';b'o,w';c'orld';
2016/8/7 8:34:46 8.56MB CVD
1
用C程序和proteus仿真音乐播放voidmain(){unchari,j;unintcodef[]={dao,re,mi,dao,dao,re,mi,dao, mi,fa,sao, mi,fa,sao, sao,la,sao,fa,mi,dao, sao,la,sao,fa,mi,dao, dao,sao,dao, dao,sao,dao, 0xff };//以0xff作为音调的结束标志uncharcodeJP[]={ 4,4,4,4,4,4,4,4, 4,4,8, 4,4,8, 6,1,6,1,4,4, 6,1,6,1,4,4, 4,4,8, 4,4,8};
2016/8/23 23:32:46 38KB C 音乐 程序
1
tcmalloc_crashgperftools问题1066的示例main.C-执行dlopen并调用已加载的.soshlib.C-打印对stdout的函数调用例子使用g++-9.2编译.so要求dlopen'ingmain()至多具有与.so一样多的tcmalloc:g++-9.2-olibcrash.so-sharedshlib.C-fPIC-ltcmallocg++-9.2-oloadermain.C-ldl$./loader./libcrash.so"hello,world"src/tcmalloc.cc:283]Attempttofreeinvalidpointer0x23c5500Abortedg++-9.2-olibcrash.so-sharedshlib.C-fPIC-ltcmallocg
2020/1/2 9:27:30 2KB C
1
一个简单的汽车租赁管理系统(C++控制台程序):利用C++实现对汽车和客户信息的增、删、改等操作,并保存。
部分代码://CarRent.cpp:定义控制台使用程序的入口点。
//#include"stdafx.h"#include"CarData.h"#include"Menu.h"#include"CustomerData.h"intmain(){ Menu::welcome(); Menu::login();//登录界面 charchoice; intcarid,customerid; //汽车编号,客户编号 CustomerDataCustomerDB; //客户库 Customer*r; //客户 CarDataCarDB; //汽车库 Car*b; //汽车 Menu::showMenu();//显示菜单 coutcustomerid; try { if(customeridcarid; try { if(caridgetNo()); coutcustomerid; try { if(customeridcarid; try { if(carid<=0) throw1; } catch(...) { cout<<"输入有误,请重新输入"; break; } r=CustomerDB.search(customerid);//按编号查找 if(r==NULL) { cout<<"不存在该客户!"<<endl; break; } b=CarDB.search(carid); if(b==NULL) { cout<<"不存在该汽车!"<getOnshelf()==1) { cout<<"该汽车已经归还!"<<endl; break; } cout<<"您成功归还一辆"
2022/9/4 11:34:28 10KB 汽车管理 出租 C++ 控制台程序
1
在实时多任务系统中,定时器的喂狗不能在像硬件编程那样在循环中喂狗。
ucos系统中,多个任务就像把程序划分成了多个main()。
喂狗也不像无系统程序那么简单,不合理的喂狗无法达到实际保护效果,附件工程是一个简单的示范历程,供大家一同学习参考,也是抛砖引玉。
2022/9/3 22:26:57 6.74MB STM32 ucos 看门狗
1
QQ、微信(WeChat)、支付宝(AliPay)的Go版本SDK。
【微信支付V3基础支付已完成,其他接口完善中...】GoPayQQ、微信、支付宝的Golang版本SDK一、安装$gogetgithub.com/iGoogle-ink/gopay查看GoPay版本版本更新记录import("fmt""github.com/iGoogle-ink/gopay")funcmain(){xlog.Debug("GoPayVersion:",gopay.Version)}微信支付API(现已支持部分V3接口,使用方法参考下面引见)希望有时间的伙伴儿Fork完后,积极提PullRequest,一起完善微信各个类别下的接口到相应的go文件中统一下单:client.UnifiedOrder()JSAPI-JSAPI支付(或小程序支付)NATIVE-Native支付APP-app支付MWEB-H5支付提
2020/1/23 14:06:31 478KB Golang Third-party APIs
1
特效运用Obj模型+shader实线加载obj格式文件加载到scene中;
运用ShaderMaterial材质。
??varShader={vertexShader:`varyingvec3vp;voidmain(){vp=position;gl_Position =projectionMatrix*modelViewMatrix*vec4(position,1.0);}`,
2015/10/11 19:04:20 9.41MB Web开发源代码 JS/Ajax源代码
1
本资源是以压缩包的方式的,里面是一个“TXT”的文档,文档中有“百度云”分享的链接,这本书太大,上传不上来,所以以这样的方式上传。
永久有效,欢迎下载。
本书作者是:NicolaiM.Josuttis,侯捷(译)内容简介:《C++标准库(第2版)》是全球C++经典权威参考书籍时隔12年,基于C++11标准的全新重大升级。
标准库提供了一组公共类和接口,极大地拓展了C++语言核心功能。
《C++标准库(第2版)》详细讲解了每一标准库组件,包括其设计目的和方法、复杂概念的剖析、实用而高效的编程细节、存在的陷阱、重要的类和函数,又辅以大量用C++11标准实现的实用代码范例。
除覆盖全新组件、特性外,《C++标准库(第2版)》一如前版,重点着眼于标准模板库(STL),涉及容器、迭代器、函数对象以及STL算法。
此外,《C++标准库(第2版)》同样关注lambda表达式、基于区间的for循环、move语义及可变参数模板等标准库中的新式C++编程风格及其影响。
部分目录:第2版译序xxi第2版序言xxiii第2版致谢xxiv第1版序言xxv第1版致谢xxvi1关于本书11.1缘起11.2阅读前的必要基础21.3本书风格与结构21.4如何阅读本书41.5目前发展情势51.6范例代码及额外信息51.7反馈52C++及标准库简介72.1C++Standard的历史72.1.1C++11Standard常见疑问82.1.2C++98和C++11的兼容性92.2复杂度与Big-O标记103语言新特性133.1C++11语言新特性133.1.1微小但重要的语法提升133.1.2以auto完成类型自动推导143.1.3一致性初始化(UniformInitialization)与初值列(InitializerList)153.1.4Range-Basedfor循环173.1.5Move语义和RvalueReference193.1.6新式的字符串字面常量(StringLiteral)233.1.7关键字noexcept243.1.8关键字constexpr263.1.9崭新的Template特性263.1.10Lambda283.1.11关键字decltype323.1.12新的函数声明语法(NewFunctionDeclarationSyntax)323.1.13带领域的(Scoped)Enumeration323.1.14新的基础类型(NewFundamentalDataType)333.2虽旧犹新的语言特性333.2.1基础类型的明确初始化(ExplicitInitializationforFundamentalType)373.2.2main()定义式374一般概念394.1命名空间(Namespace)std394.2头文件(HeaderFile)404.3差错和异常(ErrorandException)的处理414.3.1标准的ExceptionClass(异常类)414.3.2异常类(ExceptionClass)的成员444.3.3以Classexception_ptr传递异常524.3.4抛出标准异常534.3.5自标准异常类派生544.4CallableObject(可被调用的对象)544.5并发与多线程554.6分配器(Allocator)575通用工具595.1Pair和Tuple605.1.1Pair605.1.2Tuple(不定数的值组)685.1.3Tuple的输入/输出745.1.4tuple和pair转换755.2SmartPointer(智能指针)765.2.1Classshared_ptr765.2.2Classweak_ptr845.2.3误用SharedPointer895.2.4细究SharedPointer和WeakPointer925.2.5Classunique_ptr985.2.6细究Classunique_ptr1105.2.7Classauto_ptr1135.2.8SmartPointer结语1145.3数值的极值(NumericLimit)1155.4Type
2019/2/22 9:38:17 482B c++ 标准库 第2版
1
(含源码及报告)本程序分析了自2016年到2021年(外加)每年我国原油加工的产量,并且分析了2020年全国各地区原油加工量等,含饼状图,柱状图,折线图,数据在地图上显示。
运转本程序需要requests、bs4、csv、pandas、matplotlib、pyecharts库的支持,如果缺少某库请自行安装后再运转。
文件含6个excel表,若干个csv文件以及一个名字为render的html文件(需要用浏览器打开),直观的数据处理部分是图片以及html文件,可在地图中显示,数据处理的是excel文件。
不懂可以扫文件中二维码在QQ里面问。
2022/9/30 16:31:44 29.75MB 爬虫 python 源码软件 开发语言
1
在日常工作中,钉钉打卡成了我生活中不可或缺的一部分。然而,有时候这个看似简单的任务却给我带来了不少烦恼。 每天早晚,我总是得牢记打开钉钉应用,点击"工作台",再找到"考勤打卡"进行签到。有时候因为工作忙碌,会忘记打卡,导致考勤异常,影响当月的工作评价。而且,由于我使用的是苹果手机,有时候系统更新后,钉钉的某些功能会出现异常,使得打卡变得更加麻烦。 另外,我的家人使用的是安卓手机,他们也经常抱怨钉钉打卡的繁琐。尤其是对于那些不太熟悉手机操作的长辈来说,每次打卡都是一次挑战。他们总是担心自己会操作失误,导致打卡失败。 为了解决这些烦恼,我开始思考是否可以通过编写一个全自动化脚本来实现钉钉打卡。经过一段时间的摸索和学习,我终于成功编写出了一个适用于苹果和安卓系统的钉钉打卡脚本。
2024-04-09 15:03 15KB 钉钉 钉钉打卡