You are viewing a single comment's thread. Return to all comments →
C# Solution
Dictionary<string,uint> phoneList = new Dictionary<string,uint>(); int entries = int.Parse(Console.ReadLine()); while(entries > 0) { string[] entry = Console.ReadLine().Split(); string name = entry[0]; uint tel = uint.Parse(entry[1]); phoneList.Add(name, tel); entries--; } bool lookUp = true; while(lookUp) { string lookFor = Console.ReadLine(); if(lookFor == string.Empty || lookFor == null) { lookUp = false; } else { if(phoneList.ContainsKey(lookFor)) { Console.WriteLine("{0}={1}", lookFor, phoneList[lookFor]); } else Console.WriteLine("Not found"); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 8: Dictionaries and Maps
You are viewing a single comment's thread. Return to all comments →
C# Solution