using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication1 { class Lab { List work = new List(); static double MinAbs; public Lab() { List work2 = new List((Program.read().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries))); foreach (string s in work2) { work.Add(double.Parse(s)); } MinAbs = CollMinAbs(); } public double CollMinAbs() { double min = work[0]; foreach (double z in work) { if (Math.Abs(z) < Math.Abs(min)) min = z; } return min; } public int FindIndexMinAbs() { return work.FindIndex(pred1); } private static bool pred1(double s) { if (s == MinAbs) return true; else return false; } static int iter = 0; public int FindFirstNegative() { int g = work.FindIndex(pred2); if (iter < work.Count) return g; throw new Exception("Отрицательных элементов нет "); } private static bool pred2(double t) { if (t < 0) return true; else { ++iter; return false; } } public double SummInterval(int t) { double summ = 0; for (int i = t; i < work.Count; ++i) { summ += Math.Abs(work[i]); } return summ; } public int delete = 0; public void DeleteInterval() { double a = Program.parse("\nВведите первую границу интервала "); double b = Program.parse("\nВведите вторую границу интервала "); int ihelp; int index = work.Count -1; for (int i = 0; i < index - delete; ++i) { for (; work[i] >= a && work[i] <= b&& i 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; } public 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 void Main(string[] args) { try { Lab work = new Lab(); Lab.PrintList(work); Console.WriteLine(); Console.WriteLine("Номер минимального по модулю элемента " + work.FindIndexMinAbs()); Console.WriteLine("Сумма модулей элементов, согласно условию " + work.SummInterval(work.FindFirstNegative())); work.DeleteInterval(); Console.WriteLine("Удалено элементов " + work.delete); Lab.PrintList(work); } catch (Exception e) { Console.WriteLine(e.Message); } } } }