using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication1 { class Program { static string read() { string ret = ""; try { Console.Write("Введите адрес файла "); string s = Console.ReadLine(); ret = File.ReadAllText(s); } catch (Exception e) { Console.WriteLine(e.Message); Environment.Exit(0); } return ret; } static double parse(string message) { Console.Write(message); string buf = ""; double y = 1, x = 1; Boolean check; ; do { try { check = true; buf = Console.ReadLine(); x = double.Parse(buf); } catch { Console.ForegroundColor = ConsoleColor.Red; Console.Beep(300, 600); Console.WriteLine("Введённые данные неверны, повторите попытку"); Console.ForegroundColor = ConsoleColor.Gray; Console.Write(message); check = false; y++; if (y > 5) { for (int t = 3; t > 0; --t) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Программа закроется через {0} с. ", t); System.Threading.Thread.Sleep(1000); } Console.Clear(); Console.ForegroundColor = ConsoleColor.Gray; Environment.Exit(0); } } Console.ForegroundColor = ConsoleColor.Gray; } while (!check && y <= 5); return x; } static void Main(string[] args) { try { List work = new List((read().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries))); List work2 = new List(); foreach (string s in work) { work2.Add(double.Parse(s)); } Console.WriteLine(work2.BinarySearch(work2.Min())); } /* double min2 = 0; double minnom = 0; double nom = 0; foreach (double s in work2) { if (Math.Abs(s) < min) { minnom = nom; min = Math.Abs(s); min2 = s; } nom++; } nom = 0; bool check = false; List noms = new List(); foreach (double s in work2) { if (Math.Abs(s) == min && minnom != nom) { check = true; } nom++; } if (check) { nom = 0; foreach (double s in work2) { if (Math.Abs(s) == min) { noms.Add(nom); } nom++; } } Console.WriteLine("Минимальный по модулю элемент равен " + min2); if (!check) Console.WriteLine("Номер элемента " + minnom); else { Console.WriteLine("Номера элементов равных минимальному по модулю "); foreach (double s in noms) { Console.Write(s + " "); } Console.WriteLine("\n"); } foreach (double s in work2) { Console.Write(s + " "); } int index = 0; //2 задание int indexgreat = 0; check = false; foreach (double s in work2) { index++; } for (int i = 0; i < index; ++i) { if (work2[i] < 0) { check = true; indexgreat = i; break; } } double summ = 0; if (!check) { Console.WriteLine("Отрицательных элементов нет"); } else { for (int i = indexgreat; i < index; ++i) { summ += Math.Abs(work2[i]); } Console.WriteLine("\nПервый отрицательный элемент равен " + work2[indexgreat] + "\nЕго номер " + indexgreat + "\nСумма модулей элементов после него равна " + summ); } int a = (int)parse("\nВведите первую границу интервала "); //3 задание int b = (int)parse("\nВведите вторую границу интервала "); work2.RemoveRange(a, b); int index2 = 0; foreach (int d in work2) { index2++; } int delete = index - index2; for (; index2 <= index; index2++) { work2.Add(0); } Console.WriteLine("Удалено элементов " + delete); foreach (double s in work2) { Console.Write(s + " "); } Console.WriteLine(); }*/ catch (Exception e) { Console.WriteLine(e.Message); } } } }