银行家算法源程序

来源:百度知道 编辑:UC知道 时间:2024/06/19 02:41:20
如题.

-

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<iomanip>
#include<conio.h>

using namespace std;

const int MAX_P=20;
const int MAXA=10; //定义A类资源的数量
const int MAXB=5;
const int MAXC=7;

typedef struct node{
int a;
int b;
int c;
int remain_a;
int remain_b;
int remain_c;
}bank;

typedef struct node1{
char name[20];
int a;
int b;
int c;
int need_a;
int need_b;
int need_c;
}process;

bank banker;
process processes[MAX_P];
int quantity;

//初始化函数
void initial()
{
int i;

banker.a=MAXA;
banker.b=MAXB;
banker.c=MAXC;
banker.remain_a=MAXA;
banker.remain_b=MAXB;
banker.remain_c=MAXC;

for(i=0;i<MAX_P;i++){
strcpy(processes[i].name,"");
processes[