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 ConsoleApp3
- {
- class Program
- {
- static int bSearch (IEnumerable<int> array , int x)
- {
- int count = 0;
- int index =0;
- foreach ( int i in array ){
- if (i < x)
- {
- count++;
- index = count;
- IsFind = true;
- break;
- }
- else
- {
- index = -1;
- }
- }
- return index ;
- }
- static bool IsFind = false;
- static void Main(string[] args)
- {
- int[] SomeNumbers = new int[] { 51, 15, 6, 16, 74, 83, 243, 72, 2, 34, 6, 7, 8, 62, 42 };
- IEnumerable<int> SortedNumver = from i in SomeNumbers
- orderby i descending
- select i;
- int index = bSearch(SomeNumbers, 10);
- if (IsFind)
- Console.WriteLine($"Индекс:{index.ToString()}");
- else
- Console.WriteLine("Значение не найдено");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement