當前位置:首頁 » 操作系統 » 銀行家演算法c

銀行家演算法c

發布時間: 2022-01-08 20:50:28

Ⅰ 銀行家演算法(操作系統)

1、這是安全狀態:
P1的需求小於可用資源數,先滿足P1的請求,然後回收P1資源:可用資源變為 (3,3,2)+(2,0,0)=(5,3,2);
這時P3可分配,P3結束後回收資源,可用資源為(5,3,2)+(2,1,1)=(7,4,3)
這時P0可分配,P0結束後回收資源,可用資源為(7,4,3)+(0,1,0)+(7,5,3)
接下來是P2,結束後可用資源為(7,5,3)+(3,0,2)=(10,5,5)
最後分配P4,結束後可用資源為(10,5,5)+(0,0,2)=(10,5,7)
這樣得到一個安全序列:P1-P3-P0-P2-P4,所以T0狀態是安全的。

2、T0時刻P1請求(1,1,2)<可用資源數(3,3,2),可以直接滿足。

Ⅱ 急!銀行家演算法用c語言編寫.全部程序.

銀行家演算法
銀行家演算法是一種最有代表性的避免死鎖的演算法。
要解釋銀行家演算法,必須先解釋操作系統安全狀態和不安全狀態。
安全狀態:如果存在一個由系統中所有進程構成的安全序列P1,…,Pn,則系統處於安全狀態。安全狀態一定是沒有死鎖發生。
不安全狀態:不存在一個安全序列。不安全狀態不一定導致死鎖。
那麼什麼是安全序列呢?
安全序列:一個進程序列{P1,…,Pn}是安全的,如果對於每一個進程Pi(1≤i≤n),它以後尚需要的資源量不超過系統當前剩餘資源量與所有進程Pj (j < i )當前佔有資源量之和。
銀行家演算法:
我們可以把操作系統看作是銀行家,操作系統管理的資源相當於銀行家管理的資金,進程向操作系統請求分配資源相當於用戶向銀行家貸款。操作系統按照銀行家制定的規則為進程分配資源,當進程首次申請資源時,要測試該進程對資源的最大需求量,如果系統現存的資源可以滿足它的最大需求量則按當前的申請量分配資源,否則就推遲分配。當進程在執行中繼續申請資源時,先測試該進程已佔用的資源數與本次申請的資源數之和是否超過了該進程對資源的最大需求量。若超過則拒絕分配資源,若沒有超過則再測試系統現存的資源能否滿足該進程尚需的最大資源量,若能滿足則按當前的申請量分配資源,否則也要推遲分配。
演算法:
n:系統中進程的總數
m:資源類總數
Available: ARRAY[1..m] of integer;
Max: ARRAY[1..n,1..m] of integer;
Allocation: ARRAY[1..n,1..m] of integer;
Need: ARRAY[1..n,1..m] of integer;
Request: ARRAY[1..n,1..m] of integer;
符號說明:
Available 可用剩餘資源
Max 最大需求
Allocation 已分配資源
Need 需求資源
Request 請求資源
當進程pi提出資源申請時,系統執行下列
步驟:(「=」為賦值符號,「==」為等號)
step(1)若Request<=Need, goto step(2);否則錯誤返回
step(2)若Request<=Available, goto step(3);否則進程等待
step(3)假設系統分配了資源,則有:
Available=Available-Request;
Allocation=Allocation+Request;
Need=Need-Request
若系統新狀態是安全的,則分配完成
若系統新狀態是不安全的,則恢復原狀態,進程等待
為進行安全性檢查,定義數據結構:
Work:ARRAY[1..m] of integer;
Finish:ARRAY[1..n] of Boolean;
安全性檢查的步驟:
step (1):
Work=Available;
Finish=false;
step (2) 尋找滿足條件的i:
a.Finish==false;
b.Need<=Work;
如果不存在,goto step(4)
step(3)
Work=Work+Allocation;
Finish=true;
goto step(2)
step (4) 若對所有i,Finish=true,則系統處於安全狀態,否則處於不安全狀態
/* 銀行家演算法,操作系統概念(OS concepts Six Edition)
reedit by Johnny hagen,SCAU,run at vc6.0
*/
#include "malloc.h"
#include "stdio.h"
#include "stdlib.h"
#define alloclen sizeof(struct allocation)
#define maxlen sizeof(struct max)
#define avalen sizeof(struct available)
#define needlen sizeof(struct need)
#define finilen sizeof(struct finish)
#define pathlen sizeof(struct path)
struct allocation
{
int value;
struct allocation *next;
};
struct max
{
int value;
struct max *next;
};
struct available /*可用資源數*/
{
int value;
struct available *next;
};
struct need /*需求資源數*/
{
int value;
struct need *next;
};
struct path
{
int value;
struct path *next;
};
struct finish
{
int stat;
struct finish *next;
};
int main()
{
int row,colum,status=0,i,j,t,temp,processtest;
struct allocation *allochead,*alloc1,*alloc2,*alloctemp;
struct max *maxhead,*maxium1,*maxium2,*maxtemp;
struct available *avahead,*available1,*available2,*workhead,*work1,*work2,*worktemp,*worktemp1;
struct need *needhead,*need1,*need2,*needtemp;
struct finish *finihead,*finish1,*finish2,*finishtemp;
struct path *pathhead,*path1,*path2;
printf("\n請輸入系統資源的種類數:");
scanf("%d",&colum);
printf("請輸入現時內存中的進程數:");
scanf("%d",&row);
printf("請輸入已分配資源矩陣:\n");
for(i=0;i<row;i++)
{
for (j=0;j<colum;j++)
{
printf("請輸入已分配給進程 p%d 的 %c 種系統資源:",i,'A'+j);
if(status==0)
{
allochead=alloc1=alloc2=(struct allocation*)malloc(alloclen);
alloc1->next=alloc2->next=NULL;
scanf("%d",&allochead->value);
status++;
}
else
{
alloc2=(struct allocation *)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;i<row;i++)
{
for (j=0;j<colum;j++)
{
printf("請輸入進程 p%d 種類 %c 系統資源最大需求:",i,'A'+j);
if(status==0)
{
maxhead=maxium1=maxium2=(struct max*)malloc(maxlen);
maxium1->next=maxium2->next=NULL;
scanf("%d",&maxium1->value);
status++;
}
else
{
maxium2=(struct max *)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;j<colum;j++)
{
printf("種類 %c 的系統資源剩餘:",'A'+j);
if(status==0)
{
avahead=available1=available2=(struct available*)malloc(avalen);
workhead=work1=work2=(struct available*)malloc(avalen);
available1->next=available2->next=NULL;
work1->next=work2->next=NULL;
scanf("%d",&available1->value);
work1->value=available1->value;
status++;
}
else
{
available2=(struct available*)malloc(avalen);
work2=(struct available*)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;i<row;i++)
for (j=0;j<colum;j++)
{
if(status==0)
{
needhead=need1=need2=(struct need*)malloc(needlen);
need1->next=need2->next=NULL;
need1->value=maxtemp->value-alloctemp->value;
status++;
}
else
{
need2=(struct need *)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;i<row;i++)
{
if(status==0)
{
finihead=finish1=finish2=(struct finish*)malloc(finilen);
finish1->next=finish2->next=NULL;
finish1->stat=0;
status++;
}
else
{
finish2=(struct finish*)malloc(finilen);
finish2->stat=0;
if(status==1)
{
finihead->next=finish2;
status++;
}
finish1->next=finish2;
finish1=finish2;
}
}
finish2->next=NULL; /*Initialization compleated*/
status=0;
processtest=0;
for(temp=0;temp<row;temp++)
{
alloctemp=allochead;
needtemp=needhead;
finishtemp=finihead;
worktemp=workhead;
for(i=0;i<row;i++)
{
worktemp1=worktemp;
if(finishtemp->stat==0)
{
for(j=0;j<colum;j++,needtemp=needtemp->next,worktemp=worktemp->next)
if(needtemp->value<=worktemp->value)
processtest++;
if(processtest==colum)
{
for(j=0;j<colum;j++)
{
worktemp1->value+=alloctemp->value;
worktemp1=worktemp1->next;
alloctemp=alloctemp->next;
}
if(status==0)
{
pathhead=path1=path2=(struct path*)malloc(pathlen);
path1->next=path2->next=NULL;
path1->value=i;
status++;
}
else
{
path2=(struct path*)malloc(pathlen);
path2->value=i;
if(status==1)
{
pathhead->next=path2;
status++;
}
path1->next=path2;
path1=path2;
}
finishtemp->stat=1;
}
else
{
for(t=0;t<colum;t++)
alloctemp=alloctemp->next;
finishtemp->stat=0;
}
}
else
for(t=0;t<colum;t++)
{
needtemp=needtemp->next;
alloctemp=alloctemp->next;
}
processtest=0;
worktemp=workhead;
finishtemp=finishtemp->next;
}
}
path2->next=NULL;
finishtemp=finihead;
for(temp=0;temp<row;temp++)
{
if(finishtemp->stat==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");
return 0;
}

Ⅲ 「銀行家演算法」是怎樣的一個演算法

銀行家演算法=-- -

1. 安全狀態: 在某時刻系統中所有進程可以排列一個安全序列:{P1,P2,`````Pn},剛稱此時,系統是安全的.
所謂安全序列{P1,P2,`````Pn}是指對於P2,都有它所需要剩餘資源數量不大於系統掌握的剩餘的空間資源與所有Pi(j<i)所佔的資源之和.
2.不安全狀態可能產生死鎖.
目前狀態 最大需求 尚需
P1 3 9 6
P2 5 10 5
P3 2 4 2

在每一次進程中申請的資源,判定一下,若實際分配的話,之後系統是否安全.
3.銀行家演算法的思路:
1),進程一開始向系統提出最大需求量.
2),進程每次提出新的需求(分期貸款)都統計是否超出它事先提出的最大需求量.
3),若正常,則判斷該進程所需剩餘剩餘量(包括本次申請)是否超出系統所掌握的
剩餘資源量,若不超出,則分配,否則等待.
4.銀行家演算法的數據結構.
1),系統剩餘資源量A[n],其中A[n]表示第I類資源剩餘量.
2),各進程最大需求量,B[m][n],其中B[j][i]表示進程j對i
類資源最大需求.
3),已分配資源量C[m][n],其中C[j][i]表示系統j程已得到的第i資源的數量.
4),剩餘需求量.D[m][n],其中D[j][i]對第i資源尚需的數目.
5.銀行家演算法流程:當某時刻,某進程時,提出新的資源申請,系統作以下操作:
1),判定E[n]是否大於D[j][n],若大於,表示出錯.
2),判定E[n]是否大於系統剩餘量A[n],若大於,則該進程等待.
3),若以上兩步沒有問題,嘗試分配,即各變數作調整.
4),按照安全性推測演算法,判斷,分配過後,系統是否安全,若安全,則實際分配,否則,撤消分配,讓進程等待.
6."安全性檢測"演算法
1),先定義兩個變數,用來表示推算過程的數據.
F[n]=A[n],表示推算過程中,系統中剩餘資源量的變化.
J[n]=False表示推算過程中各進程是否假設"已完成"
2),流程:
在"剩餘"的進程中(在推算)過程中,一些進程假設已完成,查找D[j][n]<=F[n]的進程,找到後令J[j]=True
(假設該進程完成),F[n]+D[j][n](該進程所佔資源釋放),如此循環執行.
若最後,所有的F[n]=True(在推算過程中,所有進程均可以完成),則表示(分配過後)系統是安全的,否則系統是不安全的.
參考資料:http://huangqiyu.blogchina.com/419807.html

Ⅳ 高分求銀行家演算法c語言版

#include "malloc.h"
#include "stdio.h"
#include "stdlib.h"
#define alloclen sizeof(struct allocation)
#define maxlen sizeof(struct max)
#define avalen sizeof(struct available)
#define needlen sizeof(struct need)
#define finilen sizeof(struct finish)
#define pathlen sizeof(struct path)
struct allocation
{
int value;
struct allocation *next;
};
struct max
{
int value;
struct max *next;
};
struct available /*可用資源數*/
{
int value;
struct available *next;
};
struct need /*需求資源數*/
{
int value;
struct need *next;
};
struct path
{
int value;
struct path *next;
};
struct finish
{
int stat;
struct finish *next;
};
int main()
{
int row,colum,status=0,i,j,t,temp,processtest;
struct allocation *allochead,*alloc1,*alloc2,*alloctemp;
struct max *maxhead,*maxium1,*maxium2,*maxtemp;
struct available *avahead,*available1,*available2,*workhead,*work1,*work2,*worktemp,*worktemp1;
struct need *needhead,*need1,*need2,*needtemp;
struct finish *finihead,*finish1,*finish2,*finishtemp;
struct path *pathhead,*path1,*path2;
printf("\n請輸入系統資源的種類數:");
scanf("%d",&colum);
printf("請輸入現時內存中的進程數:");
scanf("%d",&row);
printf("請輸入已分配資源矩陣:\n");
for(i=0;i<row;i++)
{
for (j=0;j<colum;j++)
{
printf("請輸入已分配給進程 p%d 的 %c 種系統資源:",i,'A'+j);
if(status==0)
{
allochead=alloc1=alloc2=(struct allocation*)malloc(alloclen);
alloc1->next=alloc2->next=NULL;
scanf("%d",&allochead->value);
status++;
}
else
{
alloc2=(struct allocation *)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;i<row;i++)
{
for (j=0;j<colum;j++)
{
printf("請輸入進程 p%d 種類 %c 系統資源最大需求:",i,'A'+j);
if(status==0)
{
maxhead=maxium1=maxium2=(struct max*)malloc(maxlen);
maxium1->next=maxium2->next=NULL;
scanf("%d",&maxium1->value);
status++;
}
else
{
maxium2=(struct max *)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;j<colum;j++)
{
printf("種類 %c 的系統資源剩餘:",'A'+j);
if(status==0)
{
avahead=available1=available2=(struct available*)malloc(avalen);
workhead=work1=work2=(struct available*)malloc(avalen);
available1->next=available2->next=NULL;
work1->next=work2->next=NULL;
scanf("%d",&available1->value);
work1->value=available1->value;
status++;
}
else
{
available2=(struct available*)malloc(avalen);
work2=(struct available*)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;i<row;i++)
for (j=0;j<colum;j++)
{
if(status==0)
{
needhead=need1=need2=(struct need*)malloc(needlen);
need1->next=need2->next=NULL;
need1->value=maxtemp->value-alloctemp->value;
status++;
}
else
{
need2=(struct need *)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;i<row;i++)
{
if(status==0)
{
finihead=finish1=finish2=(struct finish*)malloc(finilen);
finish1->next=finish2->next=NULL;
finish1->stat=0;
status++;
}
else
{
finish2=(struct finish*)malloc(finilen);
finish2->stat=0;
if(status==1)
{
finihead->next=finish2;
status++;
}
finish1->next=finish2;
finish1=finish2;
}
}
finish2->next=NULL; /*Initialization compleated*/
status=0;
processtest=0;
for(temp=0;temp<row;temp++)
{
alloctemp=allochead;
needtemp=needhead;
finishtemp=finihead;
worktemp=workhead;
for(i=0;i<row;i++)
{
worktemp1=worktemp;
if(finishtemp->stat==0)
{
for(j=0;j<colum;j++,needtemp=needtemp->next,worktemp=worktemp->next)
if(needtemp->value<=worktemp->value)
processtest++;
if(processtest==colum)
{
for(j=0;j<colum;j++)
{
worktemp1->value+=alloctemp->value;
worktemp1=worktemp1->next;
alloctemp=alloctemp->next;
}
if(status==0)
{
pathhead=path1=path2=(struct path*)malloc(pathlen);
path1->next=path2->next=NULL;
path1->value=i;
status++;
}
else
{
path2=(struct path*)malloc(pathlen);
path2->value=i;
if(status==1)
{
pathhead->next=path2;
status++;
}
path1->next=path2;
path1=path2;
}
finishtemp->stat=1;
}
else
{
for(t=0;t<colum;t++)
alloctemp=alloctemp->next;
finishtemp->stat=0;
}
}
else
for(t=0;t<colum;t++)
{
needtemp=needtemp->next;
alloctemp=alloctemp->next;
}
processtest=0;
worktemp=workhead;
finishtemp=finishtemp->next;
}
}
path2->next=NULL;
finishtemp=finihead;
for(temp=0;temp<row;temp++)
{
if(finishtemp->stat==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");
return 0;
}

Ⅳ 銀行家演算法 C語言編程

1.根據下面給出的系統中資源分配情況,以及各個進程的資源申請情況,通過銀行家演算法來判斷各進程的資源請求能否滿足(要求記錄程序的運行過程)。 已分配的

Ⅵ 求大神!怎樣用C/C++實現銀行家演算法,並實現可視化的運行界面,界面清楚地反映出系統的運行結果

用MFC(C++)可以實現

Ⅶ c語言銀行家演算法安全性判別

把1作為參數傳給yanzheng() yanzheng(int m)

然後驗證函數里修改:

work=Avaliable;
i=m;
while(i<m)
{
if(Finish[i]==false&&Need[i]<=work)
{
work=work+Allocation[i];
Finish[i]=true;
anquan[k]=i;
k++;
i=0;
}
else
i++;
}

Ⅷ 改程序——銀行家演算法C語言版

你是學軟體的學生嗎 ?
我是學軟體的,我在操作系統里學了銀行家演算法,等我看了,在告訴你我的看法,好嗎?
願意的話希望交流一下 我的郵箱[email protected]

Ⅸ 銀行家演算法是通過破壞()來避免死鎖的。 A 互斥條件 B部分分配條件 C不可搶占條件 D循環等待條件

A肯定是不對的,A不但不能破壞還得加強,本題答案是D 循環等待條件,銀行家演算法形成一個資源分配表,這樣就不可能出現環路了

Ⅹ 銀行家演算法C++描述

#include <iostream>
#include <string>
#define M 3 //資源的種類數
#define N 5 //進程的個數

void output(int iMax[N][M],int iAllocation[N][M],int iNeed[N][M],int iAvailable[M],char cName[N]); //統一的輸出格式
bool safety(int iAllocation[N][M],int iNeed[N][M],int iAvailable[M],char cName[N]);
bool banker(int iAllocation[N][M],int iNeed[N][M],int iAvailable[M],char cName[N]);

int main()
{
int i,j;
//當前可用每類資源的資源數
int iAvailable[M]={3,3,2};
//系統中N個進程中的每一個進程對M類資源的最大需求
int iMax[N][M]={{7,5,3},{3,2,2},{9,0,2},{2,2,2},{4,3,3}};
//iNeed[N][M]每一個進程尚需的各類資源數
//iAllocation[N][M]為系統中每一類資源當前已分配給每一進程的資源數
int iNeed[N][M],iAllocation[N][M]={{0,1,1},{2,0,0},{3,0,2},{2,1,1},{0,0,2}};
//進程名
char cName[N]={'a','b','c','d','e'};
bool bExitFlag=true; //退出標記
char ch; //接收選擇是否繼續提出申請時傳進來的值

bool bSafe; //存放安全與否的標志
//計算iNeed[N][M]的值
for(i=0;i<N;i++)
for(j=0;j<M;j++)
iNeed[i][j]=iMax[i][j]-iAllocation[i][j];
//輸出初始值
output(iMax,iAllocation,iNeed,iAvailable,cName);
//判斷當前狀態是否安全
bSafe=safety(iAllocation,iNeed,iAvailable,cName);

//是否繼續提出申請
while(bExitFlag)
{
cout<<"\n"<<"繼續提出申請?\ny為是;n為否。\n";
cin>>ch;
switch(ch)
{
case 'y':
//cout<<"調用銀行家演算法";
bSafe=banker(iAllocation,iNeed,iAvailable,cName);
if (bSafe) //安全,則輸出變化後的數據
output(iMax,iAllocation,iNeed,iAvailable,cName);
break;
case 'n':
cout<<"退出。\n";
bExitFlag=false;
break;
default:
cout<<"輸入有誤,請重新輸入:\n";
}
}
}

//輸出
void output(int iMax[N][M],int iAllocation[N][M],int iNeed[N][M],int iAvailable[M],char cName[N])
{
int i,j;

cout<<"\n\t Max \tAllocation\t Need \t Available"<<endl;
cout<<"\tA B C\tA B C\tA B C\t A B C"<<endl;

for(i=0;i<N;i++)
{
cout<<cName[i]<<"\t";

for(j=0;j<M;j++)
cout<<iMax[i][j]<<" ";
cout<<"\t";

for(j=0;j<M;j++)
cout<<iAllocation[i][j]<<" ";
cout<<"\t";

for(j=0;j<M;j++)
cout<<iNeed[i][j]<<" ";
cout<<"\t";
cout<<" ";

//Available只需要輸出一次
if (i==0)
for(j=0;j<M;j++)
cout<<iAvailable[j]<<" ";

cout<<endl;
}
}

//安全性演算法,進行安全性檢查;安全返回true,並且輸出安全序列,不安全返回false,並輸出不安全的提示;
bool safety(int iAllocation[N][M],int iNeed[N][M],int iAvailable[M],char cName[N])
{
}

//定位ch對應的進程名在數組中的位置
//沒找見返回-1,否則返回數組下標
int locate(char cName[N],char ch)
{
int i;
for(i=0;i<N;i++)
if (cName[i]==ch) //找到
return i;
//未找到
return -1;
}

//提出申請,返回提出申請的進程名對應的下標
int request(char cName[N],int iRequest[M])
{
int i,loc;
char ch;
bool bFlag=true;

//判斷輸入的進程名是否有誤
while(bFlag)
{
//輸出進程名
for(i=0;i<N;i++)
cout<<cName[i]<<"\t";

//輸入提出申請的進程名
cout<<"\n輸入提出資源申請的進程名:\n";
cin>>ch;

//定位ch對應的進程名在進程名數組中的位置
loc=locate(cName,ch);
//沒找到,重新輸入
if (loc==-1)
cout<<"\n您輸入的進程名有誤!請重新輸入";
//找到,退出循環
else
bFlag=false;
}

//輸入提出申請的資源數
cout<<"輸入申請各類資源的數量:\n";
for(i=0;i<M;i++)
cin>>iRequest[i];

//返回提出申請的進程名對應的下標
return loc;
}

bool banker(int iAllocation[N][M],int iNeed[N][M],int iAvailable[M],char cName[N])
{
}

這個是c++的 我的報告

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:759
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:659
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:306
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:284
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:812
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:158
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:89
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:503
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:653
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:477