没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
using System;
namespace ConsoleApp1
{
class MainClass
{
public class BankCalculator
{
static int[] available = new int[5]; //五个资源类型
static int[,] max = new int[5, 5]; //最大资源需求
static int[,] allocation = new int[5, 5]; //已经分配的资源
static int[,] need = new int[5, 5]; //还需要的资源
static int[] request = new int[5]; //资源请求
static bool[] finish = new bool[5]; //是否有足够资源提供给进程继续运行
static int[] work = new int[5]; //当前系统可提供给进程继续运行的资源
int thread; //线程号
//利用正则判断输入是否为整数
static bool IsNumeric(string str)
{
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[0-9]\d*$");
return reg1.IsMatch(str);
}
//判断输入是否为整数并返回输入值
static int GetStr()
{
int Snum = 0;
namespace ConsoleApp1
{
class MainClass
{
public class BankCalculator
{
static int[] available = new int[5]; //五个资源类型
static int[,] max = new int[5, 5]; //最大资源需求
static int[,] allocation = new int[5, 5]; //已经分配的资源
static int[,] need = new int[5, 5]; //还需要的资源
static int[] request = new int[5]; //资源请求
static bool[] finish = new bool[5]; //是否有足够资源提供给进程继续运行
static int[] work = new int[5]; //当前系统可提供给进程继续运行的资源
int thread; //线程号
//利用正则判断输入是否为整数
static bool IsNumeric(string str)
{
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[0-9]\d*$");
return reg1.IsMatch(str);
}
//判断输入是否为整数并返回输入值
static int GetStr()
{
int Snum = 0;
string num = Console.ReadLine();
bool a = IsNumeric(num);
if (a)
return Snum = int.Parse(num.Trim());
else
Console.WriteLine("输入有误,请重新输入");
return GetStr();
}
//判断输入分配资源是否为整数且小于最大需求并返回输入值
static int GetAlo(int max)
{
int Snum = 0;
string num = Console.ReadLine();
bool a = IsNumeric(num);
if (!a)
{
Console.WriteLine("输入有误,请重新输入");
return GetAlo(max);
}
else if (int.Parse(num.Trim()) > max)
{
Console.WriteLine("输入不能大于" + max);
return GetAlo(max);
}
else
{
return Snum = int.Parse(num.Trim());
}
}
bool a = IsNumeric(num);
if (a)
return Snum = int.Parse(num.Trim());
else
Console.WriteLine("输入有误,请重新输入");
return GetStr();
}
//判断输入分配资源是否为整数且小于最大需求并返回输入值
static int GetAlo(int max)
{
int Snum = 0;
string num = Console.ReadLine();
bool a = IsNumeric(num);
if (!a)
{
Console.WriteLine("输入有误,请重新输入");
return GetAlo(max);
}
else if (int.Parse(num.Trim()) > max)
{
Console.WriteLine("输入不能大于" + max);
return GetAlo(max);
}
else
{
return Snum = int.Parse(num.Trim());
}
}
剩余13页未读,继续阅读
资源评论
hhyangel372
- 粉丝: 9
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功