Пример #1
0
        public static double[] Load(string fileName, out double min, UserChoise m)
        {
            FileStream    fs         = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            BinaryReader  bw         = new BinaryReader(fs);
            List <double> doubleList = new List <double>();

            for (int i = 0; i < fs.Length / sizeof(double); i++)
            {
                doubleList.Add(bw.ReadDouble());
            }
            bw.Close();
            fs.Close();
            min = m.fun(doubleList, m.x1, m.x2);
            return(doubleList.ToArray());
        }
Пример #2
0
        /// <summary>
        /// Меню для выбора операции над числами
        /// </summary>
        /// <returns>Делегат для запуска</returns>
        static UserChoise Menu()
        {
            bool       success = false;
            int        c;
            UserChoise Uchoice = new UserChoise();

            foreach (var item in Enum.GetValues(typeof(MenuList)))
            {
                Console.WriteLine("Для выбора функции {0} напишите {1}", item, (int)item);
            }
            while (!success)
            {
                while (!int.TryParse(Console.ReadKey().KeyChar.ToString(), out c))
                {
                    Console.WriteLine("Вы ввели не цифру, попробуйте ещё раз");
                }
                ;
                Console.WriteLine();
                switch (c)
                {
                case (int)MenuList.AVG: Uchoice.fun = AVGVal; success = true; break;

                case (int)MenuList.Max: Uchoice.fun = MaxVal; success = true; break;

                case (int)MenuList.Min: Uchoice.fun = MinVal; success = true; break;

                case (int)MenuList.Sum: Uchoice.fun = SumVal; success = true; break;

                default: Console.WriteLine("Введите ещё раз"); success = false; break;
                }
            }
            Console.WriteLine("Введите нижнюю границу поиска");
            while (!Double.TryParse(Console.ReadLine(), out Uchoice.x1))
            {
                Console.WriteLine("Вы ввели не цифру, попробуйте ещё раз");
            }
            ;
            Console.WriteLine("Введите верхнюю границу поиска");
            while (!Double.TryParse(Console.ReadLine(), out Uchoice.x2))
            {
                Console.WriteLine("Вы ввели не цифру, попробуйте ещё раз");
            }
            ;
            return(Uchoice);
        }