Alex Kulikoff avatar Alex Kulikoff committed 6b0a963

1 уровень закончен

Comments (0)

Files changed (13)

Binary file modified.

Banker/Banker.csproj

     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
+  <PropertyGroup>
+    <ApplicationIcon>
+    </ApplicationIcon>
+  </PropertyGroup>
+  <PropertyGroup />
+  <PropertyGroup>
+    <NoWin32Manifest>true</NoWin32Manifest>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Data" />

Banker/Form1.Designer.cs

 namespace Banker
 {
+    using System.Windows.Forms;
     partial class Form1
     {
         /// <summary>
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
             this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.label8 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
-            this.dataGridView1 = new System.Windows.Forms.DataGridView();
+            this.label1 = new System.Windows.Forms.Label();
+            this.table1 = new System.Windows.Forms.DataGridView();
             this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.dataGridView2 = new System.Windows.Forms.DataGridView();
+            this.table2 = new System.Windows.Forms.DataGridView();
             this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.button1 = new System.Windows.Forms.Button();
             this.button2 = new System.Windows.Forms.Button();
-            this.label1 = new System.Windows.Forms.Label();
             this.tabControl1 = new System.Windows.Forms.TabControl();
             this.tabPage1 = new System.Windows.Forms.TabPage();
             this.groupBox3 = new System.Windows.Forms.GroupBox();
             this.groupBox4 = new System.Windows.Forms.GroupBox();
             this.label2 = new System.Windows.Forms.Label();
             this.groupBox1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.table1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.table2)).BeginInit();
             this.tabControl1.SuspendLayout();
             this.tabPage1.SuspendLayout();
             this.groupBox3.SuspendLayout();
             // 
             // groupBox1
             // 
+            this.groupBox1.Controls.Add(this.label8);
             this.groupBox1.Controls.Add(this.label4);
-            this.groupBox1.Controls.Add(this.dataGridView1);
-            this.groupBox1.Controls.Add(this.dataGridView2);
+            this.groupBox1.Controls.Add(this.label1);
+            this.groupBox1.Controls.Add(this.table1);
+            this.groupBox1.Controls.Add(this.table2);
             this.groupBox1.Controls.Add(this.button1);
             this.groupBox1.Controls.Add(this.button2);
+            this.groupBox1.Enabled = false;
             this.groupBox1.Location = new System.Drawing.Point(3, 3);
             this.groupBox1.Name = "groupBox1";
             this.groupBox1.Size = new System.Drawing.Size(395, 254);
             this.groupBox1.TabIndex = 0;
             this.groupBox1.TabStop = false;
             // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Location = new System.Drawing.Point(7, 238);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(35, 13);
+            this.label8.TabIndex = 25;
+            this.label8.Text = "label8";
+            // 
             // label4
             // 
             this.label4.AutoSize = true;
             this.label4.Size = new System.Drawing.Size(0, 13);
             this.label4.TabIndex = 24;
             // 
-            // dataGridView1
+            // label1
             // 
-            this.dataGridView1.AllowUserToAddRows = false;
-            this.dataGridView1.AllowUserToDeleteRows = false;
-            this.dataGridView1.AllowUserToResizeColumns = false;
-            this.dataGridView1.AllowUserToResizeRows = false;
-            this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;
-            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(6, 181);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(25, 13);
+            this.label1.TabIndex = 19;
+            this.label1.Text = "123";
+            // 
+            // table1
+            // 
+            this.table1.AllowUserToAddRows = false;
+            this.table1.AllowUserToDeleteRows = false;
+            this.table1.AllowUserToResizeColumns = false;
+            this.table1.AllowUserToResizeRows = false;
+            this.table1.BackgroundColor = System.Drawing.SystemColors.Control;
+            this.table1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.table1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.Column1,
             this.Column2,
             this.Column3,
             this.Column5,
             this.Column6,
             this.Column7});
-            this.dataGridView1.Location = new System.Drawing.Point(6, 12);
-            this.dataGridView1.Name = "dataGridView1";
-            this.dataGridView1.ReadOnly = true;
-            this.dataGridView1.RowHeadersVisible = false;
-            this.dataGridView1.Size = new System.Drawing.Size(383, 139);
-            this.dataGridView1.TabIndex = 20;
+            this.table1.Location = new System.Drawing.Point(6, 12);
+            this.table1.Name = "table1";
+            this.table1.ReadOnly = true;
+            this.table1.RowHeadersVisible = false;
+            this.table1.ScrollBars = System.Windows.Forms.ScrollBars.None;
+            this.table1.Size = new System.Drawing.Size(383, 139);
+            this.table1.TabIndex = 20;
             // 
             // Column1
             // 
             this.Column7.ReadOnly = true;
             this.Column7.Width = 50;
             // 
-            // dataGridView2
+            // table2
             // 
-            this.dataGridView2.AllowUserToAddRows = false;
-            this.dataGridView2.AllowUserToDeleteRows = false;
-            this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.Control;
-            this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            this.dataGridView2.ColumnHeadersVisible = false;
-            this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.table2.AllowUserToAddRows = false;
+            this.table2.AllowUserToDeleteRows = false;
+            this.table2.BackgroundColor = System.Drawing.SystemColors.Control;
+            this.table2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.table2.ColumnHeadersVisible = false;
+            this.table2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.Column8,
             this.Column9,
             this.Column10,
             this.Column11});
-            this.dataGridView2.Location = new System.Drawing.Point(6, 157);
-            this.dataGridView2.Name = "dataGridView2";
-            this.dataGridView2.ReadOnly = true;
-            this.dataGridView2.RowHeadersVisible = false;
-            this.dataGridView2.Size = new System.Drawing.Size(383, 21);
-            this.dataGridView2.TabIndex = 21;
+            this.table2.Location = new System.Drawing.Point(7, 157);
+            this.table2.Name = "table2";
+            this.table2.ReadOnly = true;
+            this.table2.RowHeadersVisible = false;
+            this.table2.Size = new System.Drawing.Size(383, 21);
+            this.table2.TabIndex = 21;
             // 
             // Column8
             // 
             // 
             // button1
             // 
-            this.button1.Location = new System.Drawing.Point(84, 194);
+            this.button1.Location = new System.Drawing.Point(101, 203);
             this.button1.Name = "button1";
             this.button1.Size = new System.Drawing.Size(108, 40);
             this.button1.TabIndex = 22;
             this.button1.Text = "Дать";
             this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
             // 
             // button2
             // 
-            this.button2.Location = new System.Drawing.Point(215, 194);
+            this.button2.Location = new System.Drawing.Point(215, 203);
             this.button2.Name = "button2";
             this.button2.Size = new System.Drawing.Size(110, 40);
             this.button2.TabIndex = 23;
             this.button2.Text = "Не дать";
             this.button2.UseVisualStyleBackColor = true;
-            // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(86, 257);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(0, 13);
-            this.label1.TabIndex = 19;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
             // 
             // tabControl1
             // 
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(545, 293);
             this.Controls.Add(this.tabControl1);
-            this.Controls.Add(this.label1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
             this.MaximizeBox = false;
             this.MinimizeBox = false;
             this.Name = "Form1";
             this.Text = "Банкир";
+            this.Load += new System.EventHandler(this.Form1_Load);
             this.groupBox1.ResumeLayout(false);
             this.groupBox1.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.table1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.table2)).EndInit();
             this.tabControl1.ResumeLayout(false);
             this.tabPage1.ResumeLayout(false);
             this.groupBox3.ResumeLayout(false);
             this.groupBox4.ResumeLayout(false);
             this.groupBox4.PerformLayout();
             this.ResumeLayout(false);
-            this.PerformLayout();
 
         }
 
         #endregion
 
         private System.Windows.Forms.GroupBox groupBox1;
-        private System.Windows.Forms.DataGridView dataGridView1;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
-        private System.Windows.Forms.DataGridView dataGridView2;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column8;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column9;
         private System.Windows.Forms.DataGridViewTextBoxColumn Column10;
         private System.Windows.Forms.Label label7;
         private System.Windows.Forms.Label label6;
         private System.Windows.Forms.Label label5;
+        public System.Windows.Forms.DataGridView table1;
+       public System.Windows.Forms.DataGridView table2;
+       private Label label8;
 
-
+       
     }
 }
 
             InitializeComponent();
         }
 
-        DataGridView table1;  // таблица прцессов
-        DataGridView table2;  // таблица резерва
+        
 
         Stack<int> blockProc=new Stack<int>(); // стек содержащий индексы выполненых процессов
         Stack<int> blockRes = new Stack<int>();  // стек содержащий индексы ресурсов выполненых процессов
         int proc = 0; // индекс процесса
         int res = 0; // индекса ресурса
 
-        int[,] _temp = new int[5, 3]; // массив занимаемых ресурсов процессов
-        int[,] _max = new int[5, 3]; // массив максимальных значений процессов
+        int[] rezerv = new int[3];
+
+        Var cur;
+
+        int[,] temp = new int[3, 5]; // массив занимаемых ресурсов процессов
+        int[,] max = new int[3, 5]; // массив максимальных значений процессов
+        int[,] nul = new int[3, 5] { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }; 
 
         Random rnd = new Random(); // генератор случайных чисел
 
         string name = "";
         string group = "";
 
-        public int[,] temp
-        {
-            get { return _temp; }
-            set { _temp = value;  }
-        }
-        public int[,] max
-        {
-            get { return _max; }
-            set { _max = value; }
-        }
+        
 
         
 
 
             
         }
+        #region Варианты заданий
         Var[] var1 = new Var[9] 
-        {   new Var(new int[,] { {3, 4, 5} },new int[]{ 5}),
-            new Var(new int[,] { {4, 4, 5} }, new int[]{ 5}),
-            new Var(new int[,] { {5, 4, 5} }, new int[]{ 5}),
-            new Var(new int[,] { {4, 5, 4} }, new int[]{ 5}),
-            new Var(new int[,] { {5, 4, 5} }, new int[]{ 5}),
-            new Var(new int[,] { {4, 5, 5} }, new int[]{ 5}),
-            new Var(new int[,] { {5, 4, 5} }, new int[]{ 5}),
-            new Var(new int[,] { {5, 5, 5} }, new int[]{ 5}),
-            new Var(new int[,] { {5, 5, 4} }, new int[]{ 5}),
+        {   new Var(new int[3,5] { {3, 4, 5,0,0},{0,0,0,0,0},{0,0,0,0,0}},new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {4, 4, 5,0,0},{0,0,0,0,0},{0,0,0,0,0} }, new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {5, 4, 5,0,0} ,{0,0,0,0,0},{0,0,0,0,0}}, new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {4, 5, 4,0,0},{0,0,0,0,0},{0,0,0,0,0} }, new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {5, 4, 5,0,0},{0,0,0,0,0},{0,0,0,0,0} }, new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {4, 5, 5,0,0},{0,0,0,0,0},{0,0,0,0,0} }, new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {5, 4, 5,0,0},{0,0,0,0,0},{0,0,0,0,0} }, new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {5, 5, 5,0,0},{0,0,0,0,0},{0,0,0,0,0} }, new int[]{ 5,0,0}),
+            new Var(new int[3,5] { {5, 5, 4,0,0},{0,0,0,0,0},{0,0,0,0,0} }, new int[]{ 5,0,0}),
             
         };
 
         Var[] var2 = new Var[9] 
-        {   new Var(new int[,] { {3, 6, 4, 5},{5, 1, 4, 5} }, new int[]{6, 5}),
-            new Var(new int[,] { {5, 2, 4, 5},{3, 6, 4, 5} }, new int[]{ 5,6}),
-            new Var(new int[,] { {3, 5, 4, 6},{5, 1, 5, 5} }, new int[]{ 6,5}),
-            new Var(new int[,] { {4, 5, 6, 3},{5, 2, 4, 5} }, new int[]{ 6,5}),
-            new Var(new int[,] { {2, 6, 6, 5},{4, 1, 4, 5} }, new int[]{ 6,5}),
-            new Var(new int[,] { {2, 5, 6, 6},{5, 1, 4, 5} }, new int[]{ 6,5}),
-            new Var(new int[,] { {2, 6, 6, 5},{5, 0 ,4, 5} }, new int[]{ 6,5}),
-            new Var(new int[,] { {3, 5, 4, 5},{5, 2, 4, 5} }, new int[]{ 6,5}),
-            new Var(new int[,] { {3, 5, 4, 5},{5, 2, 4, 5} }, new int[]{ 6,5}),
+        {   new Var(new int[3,5] { {3, 6, 4, 5,0},{5, 1, 4, 5,0},{0,0,0,0,0} }, new int[]{6, 5,0}),
+            new Var(new int[3,5] { {5, 2, 4, 5,0},{3, 6, 4, 5,0},{0,0,0,0,0} }, new int[]{ 5,6,0}),
+            new Var(new int[3,5] { {3, 5, 4, 6,0},{5, 1, 5, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {4, 5, 6, 3,0},{5, 2, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {2, 6, 6, 5,0},{4, 1, 4, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {2, 5, 6, 6,0},{5, 1, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {2, 6, 6, 5,0},{5, 0 ,4, 5,0},{0,0,0,0,0} }, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {3, 5, 4, 5,0},{5, 2, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
+            new Var(new int[3,5] { {3, 5, 4, 5,0},{5, 2, 4, 5,0} ,{0,0,0,0,0}}, new int[]{ 6,5,0}),
             
         };
 
         Var[] var3 = new Var[9] 
-        {   new Var(new int[,] { {5, 0, 5, 6, 5},{6, 4, 2, 4, 5},{1, 6, 3, 5, 5} }, new int[]{7,6,6}),
+        {   new Var(new int[3,5] { {5, 0, 5, 6, 5},{6, 4, 2, 4, 5},{1, 6, 3, 5, 5} }, new int[]{7,6,6}),
             new Var(new int[,] { {6, 4, 2, 4, 5},{3, 6, 3, 5, 5},{5, 0, 4, 6, 5} }, new int[]{ 7,6,6}),
             new Var(new int[,] { {4, 2, 5, 6, 5},{6, 5, 1, 4, 5},{1, 6, 3, 5, 5} }, new int[]{ 7,6,6}),
             new Var(new int[,] { {6, 4, 2, 4, 5},{1, 6, 3, 5, 5} ,{6, 1, 5, 6, 5}}, new int[]{ 7,6,6}),
             new Var(new int[,] { {5, 0, 5, 6, 5},{6, 4, 2, 4, 5},{1, 6, 3, 5, 5 } }, new int[]{ 7,6,6}),
             
         };
+        #endregion
+        void level1(Var var) // Первый уровень, var - вариант задания
+        {
+            cur = var;
+            table1.Rows[3].Visible = false;
+            table1.Rows[4].Visible = false;
 
-        void level1(Var var) // Первый уровень, var - вариант задания
-        { }
+            table1.Columns[3].Visible = false;
+            table1.Columns[4].Visible = false;
+            table1.Columns[5].Visible = false;
+            table1.Columns[6].Visible = false;
+
+            table2.Columns[2].Visible = false;
+            table2.Columns[3].Visible = false;
+            temp = new int[3, 5];
+          copy( max, var.t);
+            var.m.CopyTo(rezerv,0);
+            reSet();
+            genQ();
+
+        }
+        void copy(int[,] x, int[,] y) 
+        {
+            for (int i = 0; i < 3; i++)
+                for (int j = 0; j < 5; j++)
+                    x[i, j] = y[i, j];
+        }
         void level2(Var var) // Второй уровень, var - вариант задания
-        { }
+        {
+            cur = var;
+            table1.Rows[3].Visible = true;
+            table1.Rows[4].Visible = false;
+
+            table1.Columns[3].Visible = true;
+            table1.Columns[4].Visible = true;
+            table1.Columns[5].Visible = false;
+            table1.Columns[6].Visible = false;
+
+            table2.Columns[2].Visible = true;
+            table2.Columns[3].Visible = false;
+            temp = new int[3, 5];
+            copy(max, var.t);
+            var.m.CopyTo(rezerv, 0);
+            reSet();
+            genQ();
+        }
         void level3(Var var) // Третий уровень, var - вариант задания
-        { }
+        {
+            cur = var;
+            table1.Rows[3].Visible = true;
+            table1.Rows[4].Visible = true;
+
+            table1.Columns[3].Visible = true;
+            table1.Columns[4].Visible = true;
+            table1.Columns[5].Visible = true;
+            table1.Columns[6].Visible = true;
+
+            table2.Columns[2].Visible = true;
+            table2.Columns[3].Visible = true;
+            temp = new int[3, 5];
+            copy(max, var.t);
+            var.m.CopyTo(rezerv, 0);
+            reSet();
+            genQ();
+        }
         void genOut() // генератор выходного файла
         { }
 
-        
+        void genQ() 
+        {
+            switch (level) 
+            {
+                case 1:  do { proc = rnd.Next(1, 4); res = 1; } while (isBlock()&&!isOver); label1.Text = "Процесс " + proc + " просит ресурс " + res; break;
+                case 2: do { proc = rnd.Next(1, 5); res = rnd.Next(1,3); } while (isBlock()); label1.Text = "Процесс " + proc + " просит ресурс " + res; break;
+                case 3: do { proc = rnd.Next(1, 6); res = rnd.Next(1,4); } while (isBlock()); label1.Text = "Процесс " + proc + " просит ресурс " + res; break;
+            }
+            if (radioButton2.Checked) if (isExist()) label8.Text = "Дать"; else label8.Text = "Не дать";
+        }
+
+        bool isBlock() 
+        {
+            return isBlock(this.proc, this.res);
+        }
+
+        bool isBlock(int proc, int res)
+        {
+            bool k = false;
+            int[] k1=blockProc.ToArray();
+            int[] k2=blockRes.ToArray();
+            for (int i = 0; i < k1.Length; i++)
+            {
+                if (k1[i] == proc && k2[i] == res) k = true;
+            }
+                return k;
+        }
+
+        bool isExist()
+        {
+            bool k = false;
+            switch (level)
+            {
+                case 1:
+                    {
+                        if (temp[res - 1, proc - 1] + rezerv[res - 1] >= max[res - 1, proc - 1])return true ;
+                        for(int i=0;i<3;i++)if(!isBlock(i+1,1)) if (temp[0, i] + rezerv[0]-1 >= max[0, i])return true ;
+                        if (rezerv[0] == 0) return false;
+                    } break;
+                case 2:
+                    {
+
+                    } break;
+                case 3: 
+                    {
+
+                    } break;
+            }
+            
+
+
+                return k;
+        }
 
         private void button3_Click(object sender, EventArgs e)
         {
+            
+            groupBox1.Enabled = true;
             if (radioButton1.Checked)
             {
                 if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
                 else { MessageBox.Show("Введите регистрационную информацию", "Ошибка"); return; }
                 blck();
                 level1(var1[rnd.Next(1,4)]);
-                genOut();
-                Application.Exit();
+                
             }
             else 
             {
                     case 2: level2(var2[variant]); break;
                     case 3: level3(var3[variant]); break;
                 }
-                unblck();
+                
             }
             
         }
             groupBox2.Enabled = true;
             groupBox3.Enabled = true;
         }
+        void reSet()
+        {
+           
+            for(int i=0;i<3;i++)
+                for (int j = 0; j < 5; j++)
+                {
+                    table1[ i * 2 + 1,j].Value = temp[ i,j];
+                    table1[ i * 2 + 2,j].Value = max[ i,j];
+                }
+            for (int i = 1; i <= 3; i++) table2[ i,0].Value = rezerv[i - 1];
+        }
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+           table1.Rows.Add("Процесс1", 0, 0, 0, 0, 0, 0);
+           table1.Rows.Add("Процесс2", 0, 0, 0, 0, 0, 0);
+           table1.Rows.Add("Процесс3", 0, 0, 0, 0, 0, 0);
+           table1.Rows.Add("Процесс4", 0, 0, 0, 0, 0, 0);
+           table1.Rows.Add("Процесс5", 0, 0, 0, 0, 0, 0);
+           table2.Rows.Add("Резерв", 5, 5, 5);
+
+           
+           
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            
+            if (isExist())
+            {
+                rezerv[res - 1] -= 1;
+                temp[res - 1, proc - 1] += 1;
+                cmp();
+                if (max[0, 0] == 0 && max[0, 1] == 0 && max[0, 2] == 0) { isOver = true; MessageBox.Show(level +" уровень закончен"); }
+                reSet();
+                if (isOver) if (radioButton1.Checked) nextLevel(); else unblck();
+            }
+            else 
+            {
+                MessageBox.Show("Ресурс не выделен");
+                temp = new int[3, 5] { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }; 
+                switch (level)
+                {
+                    case 1: var1[0].m.CopyTo(rezerv,0); break;
+                    case 2: var2[0].m.CopyTo(rezerv, 0); break;
+                    case 3: var3[0].m.CopyTo(rezerv, 0); break;
+                }
+                reSet();
+            }
+            genQ();
+        }
+
+        private void nextLevel()
+        {
+            switch (level) 
+            {
+                case 1: level2(var2[rnd.Next(9)]); break;
+                case 2: level3(var3[rnd.Next(9)]); break;
+                case 3: genOut(); break;
+            }
+        }
+
+        private bool isOver = false;
+       
+
+        private void cmp()
+        {
+            
+            for(int i=0;i<1;i++)
+                for (int j = 0; j < 3; j++)
+                {
+                    if (temp[i, j] != max[i, j] || isBlock(j + 1, i + 1)) continue;
+                    blockProc.Push(j + 1);
+                    blockRes.Push(i + 1);
+                    rezerv[res - 1] += max[i, j];
+                    temp[i, j] = max[i, j] = 0;
+
+                    
+                    reSet();
+                }
+            
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            if (!isExist()) { } else 
+            {
+                MessageBox.Show("Ресурс выделен");
+                temp = new int[3, 5] { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } };
+                copy(max, cur.t);
+                cur.m.CopyTo(rezerv, 0);
+                
+                reSet();
+            }
+            genQ();
+        }
+
     }
 }

Banker/Form1.resx

   <metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="Column11.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
   <metadata name="Column11.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="Column9.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="Column10.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="Column11.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <data name="label2.Text" xml:space="preserve">
     <value>Для выполнения лабораторной работы необходимо
  выполнить три задания в режиме тестирования. В случае

Banker/Form2.Designer.cs

             this.domainUpDown2.Items.Add("6");
             this.domainUpDown2.Items.Add("7");
             this.domainUpDown2.Items.Add("8");
-            this.domainUpDown2.Items.Add("9");
             this.domainUpDown2.Location = new System.Drawing.Point(48, 39);
             this.domainUpDown2.Name = "domainUpDown2";
             this.domainUpDown2.Size = new System.Drawing.Size(120, 20);

Banker/Properties/AssemblyInfo.cs

 using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
+using System.Resources;
 
 // Управление общими сведениями о сборке осуществляется с помощью 
 // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
 // связанные со сборкой.
 [assembly: AssemblyTitle("Banker")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyDescription("Реализует алгоритм банкира")]
 [assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("DNA Project")]
+[assembly: AssemblyCompany("ПФ НГТУ")]
 [assembly: AssemblyProduct("Banker")]
-[assembly: AssemblyCopyright("Copyright © DNA Project 2011")]
+[assembly: AssemblyCopyright("Copyright © ПФ НГТУ 2011")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.0.0.0")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguageAttribute("ru")]
Add a comment to this file

Banker/bin/Debug/Banker.exe

Binary file modified.

Add a comment to this file

Banker/bin/Debug/Banker.pdb

Binary file modified.

Banker/bin/Debug/Banker.vshost.exe.manifest

-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
-  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
-    <security>
-      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
-        <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
-      </requestedPrivileges>
-    </security>
-  </trustInfo>
-</assembly>
Add a comment to this file

Banker/obj/x86/Debug/Banker.exe

Binary file modified.

Add a comment to this file

Banker/obj/x86/Debug/Banker.pdb

Binary file modified.

Add a comment to this file

Banker/obj/x86/Debug/GenerateResource-ResGen.read.1.tlog

Binary file modified.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.