public static void Main(string[] args) { string[] tokens; tokens = Console.ReadLine().Split(' '); int n = Convert.ToInt32(tokens[0]); tokens = Console.ReadLine().Split(' '); HashTable <int> hashTable = new HashTable <int>(); foreach (string t in tokens) { hashTable.Insert(Convert.ToInt32(t), n); //fill the hash table with values } foreach (var item in hashTable) { Console.Write($"{item.Key}: "); //display the key if (item.Value != null) { foreach (var value in item.Value) //display the list of values { Console.Write($"{value} "); } } Console.WriteLine(); } }
static void Main(string[] args) { string hashArg = Console.ReadLine().Split(' ')[0]; var tokens = Console.ReadLine().Split(' '); HashTable hashTable = new HashTable(Convert.ToInt32(hashArg)); foreach (var token in tokens) { if (!String.IsNullOrWhiteSpace(token)) { hashTable.Insert(Convert.ToInt32(token)); } } foreach (var hashList in hashTable.HashLists) { Console.Write(hashList.Hash + ": "); foreach (var item in hashList) { Console.Write(item + " "); } Console.WriteLine(); } }
static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); HashTable hashTable = new HashTable(N); string[] values = Console.ReadLine().Split(' '); for (int i = 0; i < values.Length; i++) { hashTable.Insert(Convert.ToInt32(values[i])); } Console.Write(hashTable.WriteHash()); }
static void Main() { var hashArg = Console.ReadLine(); var inputString = Console.ReadLine(); var hashTable = new HashTable(int.Parse(hashArg)); foreach (var item in inputString.Split(' ')) { var number = int.Parse(item); hashTable.Insert(number); } hashTable.Display(); }
static void Main(string[] args) { int divider = Convert.ToInt32(Console.ReadLine()); HashTable table = new HashTable(divider); string[] input = Console.ReadLine().Split(' '); int[] values = new int[input.Length]; for (int i = 0; i < input.Length; i++) { values[i] = int.Parse(input[i]); table.Insert(values[i]); } table.PrintAllValues(); }
static void Main(string[] args) { string[] tokens; tokens = Console.ReadLine().Split(' '); HashTable ht = new HashTable(Convert.ToInt32(tokens[0])); tokens = Console.ReadLine().Split(' '); foreach (string item in tokens) { ht.Insert(Convert.ToUInt32(item)); } ht.ShowTable(); }
private static void Main(string[] args) { var N = Convert.ToInt32(Console.ReadLine()); var tokens = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); var table = new HashTable(N); foreach (var t in tokens) { table.Insert(Convert.ToInt32(t)); } for (var i = 0; i < table.Values.Length; i++) { var elements = GetElementsString(table.Values[i]); Console.WriteLine($"{i}: {elements}"); } }