Cin> The name [I];
Cin> Avaiable [I];
}
Cout<& lt;" Please enter the Max "& lt;
Cout<& lt;" Please enter the Allocation "& lt;
for(i=0; I
Cout<& lt;" Please input the name of the process "& lt;
Cin> Job [I]. Name;
Job [I]. Finish=0;
Size++;
}
Cout<& lt;" System is currently available resources Avaliable "& lt;
for(j=0; j<3; J++)
{
for(i=0; I
}
Cout
Cout<& lt;" "& lt;
for(j=0; j
for(j=0; j
Cout
}
//security algorithm
Void safe ()
{
Int I, j, L;
L=0;
int f;
Int q=0;
[100] int w={0};
Int Q [100];
for(i=0; I
Int k=0;
While (1)
{
for(i=0; I
F=1;
for(j=0; j
If (Need [I] [j] & gt; W [j])
{
F=0;
break;
}
}
If (Job [I]. Finish==0 & amp; & F==1)
{
for(j=0; j
Job [I]. Finish=1;
Q [Q]=I;
Q++;
K=k + 1;
break;
}
}
L++;
If (L==n + 2)
{
Cout<& lt;" Unsafe conditions "& lt;
break;
}
If (k==n)
{
Cout<& lt;" System security "& lt;
for(i=0; I
}
}
for(i=0; I
}
//the application resources function
Void (TT)
{
int i;
Int b=1, c=1;
Cout<& lt;" Please select the application process of resources "& lt;
Cout<& lt;" Please enter the number of all the resources & lt;"
for(i=0; I
If (request [a] [I] & gt; Need [a] [I])
{
B=0;
Pan=0;
break;
}
}
for(i=0; I
If (request [a] [I] & gt; Avaiable [I])
{
c=0;
Pan=0;
break;
}
}
If (b==1 & amp; & C==1)
{
for(i=0; I
Avaiable [I]=Avaiable [I] - request [a] [I];
Need [a] [I]=Need [a] [I] - request [a] [I];
Allocation of [a] [I]=Allocation request [a] [I] + [a] [I];
}
}
}
//the application failed to return data function
Void of TD ()
{
int i;
for(i=0; I
Avaiable [I]=Avaiable request [I] + [a] [I];
Need [a] [I]=Need [a] [I] + request [a] [I];
Allocation of [a] [I]=Allocation [a] [I] - request [a] [I];
}
}
};
Int main ()
{
The work s;
Int T;
Int V=1;
S.i n_put ();
S.s afe ();
While (V!=0)
{
Cout<& lt;" Please choose whether or not the application resources "& lt; & lt;" : 1:2: no "& lt;
The switch (T)
{
Case 1: s.T (T);
If (pan==0)
{
S.T (D);
Cout<& lt;" Don't agree to apply for "& lt;
}
S.s afe ();
If (pan==0)
{
S.T (D);
Cout<& lt;" Don't agree to apply for "& lt;
The else
Cout
Case 2: V=0;
break;
}
}
return 0;
}