Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //using System.Collections.Generic;
- //using System.Linq;
- //using System.Text;
- //using System.Threading.Tasks;
- namespace phoneBook
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] phoneNumbers = Console.ReadLine().Split(' ');
- string[] names = Console.ReadLine().Split(' ');
- string[] ownNames = new string[names.Length];
- var index = 0;
- int[] indexInNames = new int[150/*names.Length*/];/*защото незнаеш колко имена
- ще се опитат да търсят и дали са в списъка.Taka си почти сигурен примерно че няма да има
- повече от 50 сърча - затова и ти гърми с рънтаим ерор защото примерите са с по малко сърчове*/
- //var run = true;
- var searches = new string[150]; /*за да събираш сърчовете*/
- var input = Console.ReadLine();
- while (input != "done")
- {
- //var input = Console.ReadLine();
- //if (input == "done")
- //{
- // run = false;
- //}
- searches[index] = input;
- index++;
- input = Console.ReadLine();
- }
- var indexInIndexes = 0;
- for (int i = 0; i < names.Length; i++)
- {
- for (int y = 0; y < index; y++)/*понеже до сега добавя имена в масив и тепърва почбаш да
- ги проверяваш с цикъл до индекс си спестяваш следващите примерно 40 итернации*/
- {
- if (names[i] == searches[y])
- {
- indexInNames[indexInIndexes] = i;
- indexInIndexes++;
- break; // за да не върти излишно
- }
- }
- }
- for (int i = 0; i < indexInIndexes; i++)
- {
- index = indexInNames[i];/*вземаш стоиноста от i и по нея печаташ и едновременно
- преизползваш index които не ти трябва повече*/
- //if (indexInNames[i] == )
- //{
- Console.WriteLine(names[index] + " -> " + phoneNumbers[index]);
- //}
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement