没有合适的资源?快使用搜索试试~ 我知道了~
C#银行家算法(考虑安全问题)
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
![preview](https://dl-preview.csdnimg.cn/txt_preview/3312610/3312610_thumbnail_1.jpg?x-oss-process=style/thumbnail)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
7页
C#银行家算法(考虑安全问题) private int m; private int n; private int[] Available; private int[][] Max; private int[][] Allocation; private int[][] Need; private readonly char[] sprit ={ ' ', '\t', '\n' };
资源推荐
资源详情
资源评论
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![text/plain](https://img-home.csdnimg.cn/images/20210720083646.png)
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
using System;
using System.Collections.Generic;
using System.Text;
namespace BankerAlgorithm
{
class Program
{
/*@ n: the number of processes
*@ m: the number of available resources of each type
*@ Available: A vector of length m indicates the numnber of available resources of each type
*@ Max: An n * m matrix defines the maximum demand of each process
*@ Allocation: An n * m matrix defines the number of resources of each type currently allocated to each process.
*@ Need: An n * m matrix indicates the remaining resource need of each process
*/
private int m;
private int n;
private int[] Available;
private int[][] Max;
private int[][] Allocation;
private int[][] Need;
private readonly char[] sprit ={ ' ', '\t', '\n' };
Program()
{
Initialize();
}
//get data from standard input
using System.Collections.Generic;
using System.Text;
namespace BankerAlgorithm
{
class Program
{
/*@ n: the number of processes
*@ m: the number of available resources of each type
*@ Available: A vector of length m indicates the numnber of available resources of each type
*@ Max: An n * m matrix defines the maximum demand of each process
*@ Allocation: An n * m matrix defines the number of resources of each type currently allocated to each process.
*@ Need: An n * m matrix indicates the remaining resource need of each process
*/
private int m;
private int n;
private int[] Available;
private int[][] Max;
private int[][] Allocation;
private int[][] Need;
private readonly char[] sprit ={ ' ', '\t', '\n' };
Program()
{
Initialize();
}
//get data from standard input
public void Initialize()
{
Console.Write("Please enter the number of processes (n) : ");
n=Int32.Parse(Console.ReadLine());
Console.Write("Please enter the number of available resources of each type (m) : ");
m = Int32.Parse(Console.ReadLine());
Available=new int[m];
Console.WriteLine("Enter the available resources of each type.(Available)");
ReadOneDimension(Available);
Max=new int[n][];
for (int i = 0; i < n; i++)
Max[i] = new int[m];
Allocation = new int[n][];
for (int i = 0; i < n; i++)
Allocation[i] = new int[m];
Need = new int[n][];
for (int i = 0; i < n; i++)
Need[i] = new int[m];
Console.WriteLine("Enter the matrix which indicates the maximum demand of each process.(Max)");
ReadMaxtrix(Max);
Console.WriteLine("Enter the matrix which indicates the number of resources of each type currently allocated to each process.(Allocation)");
ReadMaxtrix(Allocation);
//because Need[i,j] = Max[i,j] - Allocation[i,j]
{
Console.Write("Please enter the number of processes (n) : ");
n=Int32.Parse(Console.ReadLine());
Console.Write("Please enter the number of available resources of each type (m) : ");
m = Int32.Parse(Console.ReadLine());
Available=new int[m];
Console.WriteLine("Enter the available resources of each type.(Available)");
ReadOneDimension(Available);
Max=new int[n][];
for (int i = 0; i < n; i++)
Max[i] = new int[m];
Allocation = new int[n][];
for (int i = 0; i < n; i++)
Allocation[i] = new int[m];
Need = new int[n][];
for (int i = 0; i < n; i++)
Need[i] = new int[m];
Console.WriteLine("Enter the matrix which indicates the maximum demand of each process.(Max)");
ReadMaxtrix(Max);
Console.WriteLine("Enter the matrix which indicates the number of resources of each type currently allocated to each process.(Allocation)");
ReadMaxtrix(Allocation);
//because Need[i,j] = Max[i,j] - Allocation[i,j]
剩余6页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- 肥羊爱看书2012-11-26这个算法多我这个初学者来说很有用
![avatar](https://profile-avatar.csdnimg.cn/5913c1b4b2744a1db901eadfa0e72857_luckstar123321.jpg!1)
Luckstar
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)