银行家算法
#include <cstdlib>
#include <windows.h>
#include <tchar.h>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int n = 4;//进程数
const int m = 3;//资源数
struct state{
int resource[m];
int available[m];
int claim[n][m];
int alloc[n][m];
int need[n][m];
};
state bank;
void init_input(){
cout << "输入进程资源:"<<endl;
for(int i = 0; i < m; i++){
cin >> bank.resource[i];
}
cout << "输入当前可用资源:"<<endl;
for(int i = 0; i < m; i++){
cin >> bank.available[i];
}
cout << "输入进程所需最大资源数:"<<endl;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> bank.claim[i][j];
}
}
cout << "输入进程已经分配资源数:"<<endl;