return;
}
if (request[i] > Available[i]) {
cout << "请求的资源超过了可用的量!" << endl;
return;
}
}
for (int i = 0; i < 3; i++) {
Available[i] -= request[i];
Allocation[n][i] += request[i];
Need[n][i] -= request[i];
}
SafeCheck();
}
int main() {
int choice;
while (true) {
cout << "1. 显示当前资源情况" << endl;
cout << "2. 请求资源" << endl;
cout << "3. 退出" << endl;
cout << "选择操作:";
cin >> choice;
switch (choice) {
case 1:
Show();
break;
case 2:
RequestResource();
break;
case 3:
cout << "退出程序。" << endl;
return 0;
default:
cout << "无效输入,请重新选择。" << endl;
}
}
}
银行家算法
最新推荐文章于 2024-08-05 20:49:33 发布