LukasRiedel

ADS - Matičky

Apr 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. class Sroubky_A_Maticky
  2. {
  3.     public struct CoKamPasuje
  4.     {
  5.         public int Co;
  6.         public int Kam;
  7.     }
  8.  
  9.     public List<CoKamPasuje> Tabulka = new List<CoKamPasuje>();
  10.     private List<int> Sroubky = new List<int>();
  11.     private Hashtable Maticky;
  12.     public Sroubky_A_Maticky(List<int> Sroubky, List<int> Maticky)
  13.     {
  14.         this.Sroubky = Sroubky;
  15.         this.Maticky = new Hashtable(Maticky.Count);
  16.  
  17.         for (int i = 0; i < Maticky.Count; i++)
  18.             this.Maticky.Add(Maticky[i], i);
  19.     }
  20.  
  21.     public void NajdiOdpovidajiciDvojice()
  22.     {
  23.         for (int i = 0; i < Sroubky.Count; i++)
  24.             if (Maticky.ContainsKey(Sroubky[i]))
  25.             {
  26.                 CoKamPasuje JedenVyskyt;
  27.                 JedenVyskyt.Co = i;
  28.                 JedenVyskyt.Kam = (int)Maticky[Sroubky[i]];
  29.                 Tabulka.Add(JedenVyskyt);
  30.             }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment