Forráskód Böngészése

addingCheckClouserAndVyrozdennost

7 2 hónapja
szülő
commit
0d485e102e
1 módosított fájl, 31 hozzáadás és 3 törlés
  1. 31 3
      MinElKuzminEkz/Program.cs

+ 31 - 3
MinElKuzminEkz/Program.cs

@@ -108,11 +108,39 @@ namespace MinElKuzminEkz
     }
 
     //класс utility
-    internal class Utility
+    public static class Utility
     {
+        public static bool CheckClosure(int[] a, int[] b)
+        {
+            int sum_a = a.Sum();
+            int sum_b = b.Sum();
+            Debug.WriteLine($"Проверка на закрытость задачи: A = {sum_a}, B = {sum_b}");
+            return sum_a == sum_b;
+        }
+
+        public static bool CheckIfVyrozhdeno(int[,] supply_plan)
+        {
+            int n = supply_plan.GetLength(0);
+            int m = supply_plan.GetLength(1);
+
+            int kolvo_polozh_komponent = 0;
+            for (int i = 0; i < n; i++)
+            {
+                for (int j = 0; j < m; j++)
+                {
+                    if (supply_plan[i, j] > 0)
+                    {
+                        kolvo_polozh_komponent++;
+                    }
+                }
+            }
+
+            Debug.WriteLine($"Проверка вырожденности A = {kolvo_polozh_komponent}, B = {n + m - 1}");
+            return kolvo_polozh_komponent != n + m - 1;
+        }
+
+        
 
-    }
-    
 }