xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

資源簡介

利用C語言實(shí)現(xiàn)操作系統(tǒng)中的銀行家算法(話說說的這么清楚還需要多少描述嗎?額,我這個(gè)是老師親自驗(yàn)收通過的!)

資源截圖

代碼片段和文件信息

#include?
using?namespace?std;
#define?maxprocess?30????????????????????????/*最大進(jìn)程數(shù)*/
#define?maxresource?80????????????????????????/*最大資源數(shù)*/
int?available[maxresource];????????????????????/*可用資源數(shù)組*/
int?max[maxprocess][maxresource];????????????/*最大需求矩陣*/
int?allocation[maxprocess][maxresource];????/*分配矩陣*/
int?need[maxprocess][maxresource];????????????/*需求矩陣*/
int?request[maxprocess][maxresource];????????/*進(jìn)程需要資源數(shù)*/
bool?finish[maxprocess];????????????????????????/*系統(tǒng)是否有足夠的資源分配*/
int?p[maxprocess];?????????????????????????????/*記錄序列*/
int?mn;????????????????????????????????????/*m個(gè)進(jìn)程n個(gè)資源*/
void?Init();
bool?Safe();
void?Bank();
void?main()
{
????Init();
????Safe();
????Bank();
}
void?Init()????????????????/*初始化算法*/
{
????int?ij;
cout<<“**********************************銀行家算法**********************************“<????cout<<“請(qǐng)輸入進(jìn)程的數(shù)目:“<????cin>>m;
????cout<<“請(qǐng)輸入資源的種類:“<????cin>>n;
????cout<<“請(qǐng)輸入每個(gè)進(jìn)程最多所需的各資源數(shù)按照“<????for(i=0;i????for(j=0;j????cin>>max[i][j];
????cout<<“請(qǐng)輸入每個(gè)進(jìn)程已分配的各資源數(shù)也按照“<????for(i=0;i????{
????????for(j=0;j????????{
????????????cin>>allocation[i][j];
????????????need[i][j]=max[i][j]-allocation[i][j];
????????????if(need[i][j]<0)
????????????{
????????????????cout<<“您輸入的第“<????????????????j--;
????????????????continue;
????????????}
????????}
????}
????cout<<“請(qǐng)輸入各個(gè)資源現(xiàn)有的數(shù)目:“<????for(i=0;i????{
????????cin>>available[i];
????}
}
void?Bank()????????????????/*銀行家算法*/
{
????int?icusneed;
????char?again;
????while(1)
????{
????????cout<<“請(qǐng)輸入要申請(qǐng)資源的進(jìn)程號(hào)(請(qǐng)從0開始依次輸入)“<????????cin>>cusneed;
????????cout<<“請(qǐng)輸入進(jìn)程所請(qǐng)求的各資源的數(shù)量“<????????for(i=0;i????????{
????????????cin>>request[cusneed][i];
????????}
????????for(i=0;i????????{
????????????if(request[cusneed][i]>need[cusneed][i])
????????????{
????????????????cout<<“您輸入的請(qǐng)求數(shù)超過進(jìn)程的需求量!請(qǐng)重新輸入!“<????????????????continue;
????????????}
????????????if(request[cusneed][i]>available[i])
????????????{
????????????????cout<<“您輸入的請(qǐng)求數(shù)超過系統(tǒng)有的資源數(shù)!請(qǐng)重新輸入!“<???

評(píng)論

共有 條評(píng)論

相關(guān)資源