skipter

C# Two Arrays - PhoneBook

Jun 24th, 2017
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace _3.Phonebook
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] phoneNumbers = Console.ReadLine().Split(' ').ToArray();
  11.             string[] phoneNames = Console.ReadLine().Split(' ').ToArray();
  12.             string input = Console.ReadLine();
  13.                            
  14.             while (input != "done")
  15.             {              
  16.                 for (int cnt = 0; cnt < phoneNames.Length; cnt++)
  17.                 {
  18.                     if (input == phoneNames[cnt])
  19.                     {
  20.                         Console.WriteLine($"{phoneNames[cnt]} -> {phoneNumbers[cnt]}");
  21.                         break;
  22.                     }
  23.                 }
  24.                 input = Console.ReadLine();
  25.             }    
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment