Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Phonebook
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- List<string> listOfNumbers = Console.ReadLine().Split().ToList();
- List<string> listOfNames = Console.ReadLine().Split().ToList();
- List<string> resultNames = new List<string>();
- List<string> resultNumbers = new List<string>();
- string name = string.Empty;
- while((name=Console.ReadLine()) != "done")
- {
- if (listOfNames.Exists(x => x == name))
- {
- int indexOfPersonalName=listOfNames.IndexOf(name);
- string numberOfPersonalName = listOfNumbers[indexOfPersonalName];
- resultNames.Add(name);
- resultNumbers.Add(numberOfPersonalName);
- }
- }
- for (int i = 0; i < resultNames.Count; i++)
- {
- Console.WriteLine($"{resultNames[i]} -> {resultNumbers[i]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement