-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBankers.cpp
More file actions
36 lines (30 loc) · 937 Bytes
/
Bankers.cpp
File metadata and controls
36 lines (30 loc) · 937 Bytes
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
#include<bits/stdc++.h>
using namespace std;
int processNum, resourceNum, id, maxR, allocR, needR, freeResources, i, x;
vector<vector<int>> processes;
void processInput(){
cout<<"Enter no. of processes : ";
cin>>processNum;
cout<<"Enter total no. of resources : ";
cin>>resourceNum;
cout<<"Enter process id, max need of resources, allocated resources for each process : "<<endl;
for(i=0; i<processNum; i++){
cin>>id>>maxR>>allocR;
needR = maxR - allocR;
processes.push_back({id, maxR, allocR, needR});
freeResources = resourceNum - allocR;
}
cout<<"\n\nFree Resources left : "<<freeResources<<endl;
cout<<"\n\nProcess ID\tMax Res\tAllocated Res\tNeed Res\n";
for(auto i : processes){
cout<<i[0]<<"\t"<<i[1]<<"\t"<<i[2]<<"\t"<<i[3]<<"\n";
}
}
void Bankers(){
if(freeResources < )
}
int main(){
processInput();
Bankers();
return 0;
}