Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 KB | None | 0 0
  1. public void algorytm2(string[,] macierz, char[,] system)
  2.         {
  3.  
  4.             char[] kombinacje = {'1','2', '3', '4', '5', '6' };
  5.             List<string> zasady = new List<string>();
  6.             List<int> krotnosc = new List<int>();
  7.  
  8.             for(int i = 0; i < 8; i++)
  9.             {
  10.  
  11.                 List<char> kol = new List<char>();
  12.  
  13.                 for (int j = 0; j < 8; j++)
  14.                 {
  15.                     //kol wiersz
  16.                     if (macierz[i, j] == "Null") continue;
  17.  
  18.                     for(int h = 0; h < macierz[i,j].Length; h++)
  19.                     {
  20.                         string test = macierz[i, j];
  21.                         if(!kol.Contains(test[h]))
  22.                         {
  23.                             kol.Add(test[h]);
  24.                         }
  25.  
  26.                     }
  27.  
  28.  
  29.  
  30.                 }
  31.  
  32.  
  33.                 for (int j = 0; j < kombinacje.Length; j++)
  34.                 {
  35.                     if (!kol.Contains(kombinacje[j]))
  36.                     {
  37.                        
  38.                         char a = kombinacje[j];
  39.                         char wynik = system[6, i];
  40.                         int indeks = a - '0';
  41.                         char co = system[indeks - 1, i];
  42.                        
  43.  
  44.                         string zasada = "(a" + a + " = " + co + ") => (d = " + wynik + ")";
  45.                        
  46.                         if(!zasady.Contains(zasada))
  47.                         {
  48.                             zasady.Add(zasada);
  49.                             krotnosc.Add(1);
  50.                         }
  51.                         else
  52.                         {
  53.                             int licznik = 0;
  54.  
  55.                             for (int g = 0; g < zasady.Count; g++)
  56.                             {
  57.                                 if (zasady[g] == zasada) licznik = g;
  58.                             }
  59.                             krotnosc[licznik] = krotnosc[licznik] + 1;
  60.  
  61.                         }
  62.                     }
  63.                 }
  64.  
  65.  
  66.                
  67.             }
  68.  
  69.             for(int i = 0; i < zasady.Count; i++ )
  70.             {
  71.                if(krotnosc[i] != 1) Console.WriteLine(zasady[i] + "["+krotnosc[i]+"]");
  72.                 else Console.WriteLine(zasady[i]);
  73.             }
  74.  
  75.         }
  76.  
  77.  
  78.  
  79.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement