DapperDrake

ArrSearch001

Jul 15th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. class FruitSearcher {
  2.  
  3.     static void Main(string[] args)
  4.     {
  5.  
  6.     string[] Fruit = {"Apple", "Oragne", "Banana", "Chery"};
  7.     Console.WriteLine("Введите название какойго либо фрукта из списка ниже!");
  8.     Console.WriteLine("Apple", "Oragne", "Banana", "Chery", "Watermelon");
  9.         //
  10.         //Сортируем массив
  11.         //
  12.     Array.Sort(Fruit);
  13.         foreach(string i in Fruit)
  14.             Console.WriteLine(i);
  15.         //
  16.         //Ищем нужные значения
  17.         //
  18.             var x = "";
  19.             Console.ReadLine(x);
  20.     Console.WriteLine('Ищем фрукту');
  21.     string search = Array.BinarySearch(Fruit, x);
  22.     Console.WriteLine("Название твоего фрукта находится на {0} позиции", search + 1);
  23.         Console.ReadLine();
  24.  
  25.      
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment