Example #1
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            string str1 = string.Empty, str2 = string.Empty;
            var    specFunc = new UtilityForStudy();

            Console.WriteLine("Это программа проверяет являетсяли строки " +
                              "перестановками друг друга");
            Console.WriteLine("Введите первую строку:");
            str1 = Console.ReadLine();
            Console.WriteLine("Введите второю строку:");
            str2 = Console.ReadLine();

            Console.WriteLine(string.Format("Строка 1: {0}\nСтрока 2: {1}",
                                            str1, str2));

            Console.WriteLine(string.Format(TaskA(str1, str2) ?
                                            "Строка 2 является перестановкой строки 1" : "Строка 2 не " +
                                            "является перестановкой строки 1"));

            Console.WriteLine(string.Format(CheckStringReshuffle(str1, str2) ?
                                            "Строка 2 является перестановкой строки 1" : "Строка 2 не " +
                                            "является перестановкой строки 1"));

            specFunc.Pause();
        }
Example #2
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var     specFunc = new UtilityForStudy();
            Complex a        = new Complex(7);
            Complex b        = new Complex(10, 20);
            Complex c        = new Complex();
            Complex d        = b;

            Console.WriteLine(string.Format("a = {0}, b = {1}, " +
                                            "c = {2}, d = {3}\n", a, b, c, d));

            Console.WriteLine(string.Format("-d = {0}", -d));
            Console.WriteLine(string.Format("a + b = {0} + {1} = {2}", a, b, a + b));
            Console.WriteLine(string.Format("d - a = {0} - {1} = {2}", d, a, d - a));
            Console.WriteLine(string.Format("b * (a + d) = {0} * ({1} + {2}) = {3}", b, a, d, b * (a + d)));
            Console.WriteLine(string.Format("b * b = {0} * {0} = {1}", b, b * b));
            //Console.WriteLine();
            //Console.WriteLine(string.Format("b == d = {0} == {1} = {2}", b, d, b == d));
            //Console.WriteLine(string.Format("b != d = {0} != {1} = {2}", b, d, b != d));
            //Console.WriteLine(string.Format("a == c = {0} == {1} = {2}", a, c, a == c));
            //Console.WriteLine(string.Format("a != c = {0} != {1} = {2}", a, c, a != c));


            specFunc.Pause();
        }
Example #3
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var  specFunc = new UtilityForStudy();
            bool isGame   = true;

            do
            {
                Console.WriteLine("Выберите:\n" +
                                  "1 - запустить викторину;\n" +
                                  "0 - выход.\n");
                switch (Console.ReadKey(false).KeyChar)
                {
                case '1':
                    Console.Clear();
                    Console.WriteLine(string.Format("Количество правильных ответов: {0}", StartQuiz()));
                    specFunc.Pause();
                    break;

                case '0':
                    isGame = false;
                    break;

                default:
                    break;
                }
                Console.Clear();
            } while (isGame);
            specFunc.Pause();
        }
Example #4
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var    specFunc = new  UtilityForStudy();
            int    tries    = 3;
            string login    = string.Empty;
            string password = string.Empty;

            //Console.WriteLine((int)Console.ReadKey(true).KeyChar);

            do
            {
                if (tries <= 0)
                {
                    specFunc.Print("\nУ вас закончились попытки.\nДоступ закрыт.\n");
                    specFunc.Pause();
                    return;
                }
                else if (tries < 3)
                {
                    specFunc.Print(string.Format("\nУ вас осталось {0} попытки.\n", tries));
                }
                specFunc.Print("Введите логин:\n");
                login = Console.ReadLine();
                specFunc.Print("Введите пароль:\n");
                password = ReadPassword();
                //password = Console.ReadLine();

                tries--;
            } while (!CheckPassword(login, password));


            Console.WriteLine($"\nВы вошли в программу под {login}.");
            specFunc.Pause();
        }
Example #5
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            const double indexMassMax = 24.9;
            const double indexMassMin = 18.6;


            var specFunc = new  UtilityForStudy();

            Console.WriteLine("Введите массу тела в килограммах.");
            double m = double.Parse(Console.ReadLine());

            Console.WriteLine("Введите рост тела в метрах.");
            double h  = double.Parse(Console.ReadLine());
            double im = IndexMass(m, h);

            double bestM = 21 * h * h;

            if (im < indexMassMin - 0.1)
            {
                Console.WriteLine(string.Format("Вам необходимо набрать {0:F2} кг.\nВам желательно набрать {1:F2} кг.", indexMassMin * h * h - m, bestM - m));
            }
            else if (im > indexMassMax + 0.1)
            {
                Console.WriteLine(string.Format("Вам необходимо похудеть на {0:F2} кг.\nВам желательно похудеть на {1:F2} кг.", m - indexMassMax * h * h, m - bestM));
            }
            else
            {
                Console.WriteLine(string.Format("Вам вес находится в пределах нормы."));
            }

            specFunc.Pause();
        }
Example #6
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var specFunc = new UtilityForStudy();

            //TaskA();
            TaskB();
            specFunc.Pause();
        }
Example #7
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var specFunc = new UtilityForStudy();

            Console.WriteLine("Введите имя файла для поиска номеров.");
            PrintAllNumbers(LoadText(Console.ReadLine()).Split(' ', '\n', '\t', '\r'));

            specFunc.Pause();
        }
Example #8
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var specFunc = new UtilityForStudy();

            Task5("data.bin", 10_000_000);
            //Save("data.bin", 10_000_000);
            //Load2("data.bin");

            specFunc.Pause();
        }
Example #9
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var    specFunc = new UtilityForStudy();
            string src      = @"C:\temp";

            Console.WriteLine("Введите имя файла для html файлов.");
            PrintAllNumbers(LoadText(Console.ReadLine()).Split('<', '>'));
            //PrintAllNumbers(LoadText(src).Split('<', '>'));


            specFunc.Pause();
        }
Example #10
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            const int cntArrEl = 20;
            var       specFunc = new UtilityForStudy();

            int[] arr = new int[cntArrEl];

            for (int i = 0; i < cntArrEl; i++)
            {
                arr[i] = int.Parse(Console.ReadLine());
            }
            Console.WriteLine(CountOfPair(arr));
            specFunc.Pause();
        }
Example #11
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var      specFunc = new UtilityForStudy();
            MyString str      = new MyString("Privet Ya chelovek, a ti kto? Albolite");

            Console.WriteLine(str);
            Console.WriteLine(str.WordsLessNLetters(4));
            Console.WriteLine(str.WordsDeleteLastLetter('a'));
            Console.WriteLine(str.FirstMaxLengthWord());
            string[] strArr = str.MaxLengthWords();
            Console.WriteLine();
            for (int i = 0; i < strArr.Length; i++)
            {
                Console.WriteLine(strArr[i]);
            }

            specFunc.Pause();
        }
Example #12
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var      specFunc = new UtilityForStudy();
            Fraction a = new Fraction(7);
            Fraction b = new Fraction(10, 20);
            Fraction c = new Fraction();
            Fraction d = b, e = new Fraction(15, 7), f = new Fraction(21, 20);

            Console.WriteLine(string.Format("a = {0}, b = {1}, " +
                                            "c = {2}, d = {3}, e = {4}, f = {5}\n", a, b, c, d, e, f));

            Console.WriteLine(string.Format("-d = {0}", -d));
            Console.WriteLine(string.Format("a + b = {0} + {1} = {2}", a, b, a + b));
            Console.WriteLine(string.Format("d - a = {0} - {1} = {2}", d, a, d - a));
            Console.WriteLine(string.Format("b * (a + d) = {0} * ({1} + {2}) = {3}", b, a, d, b * (a + d)));
            Console.WriteLine(string.Format("b * b = {0} / {0} = {1}", b, b / b));
            Console.WriteLine(string.Format("e * f = {0} * {1} = {2}", e, f, e * f));
            Console.WriteLine(string.Format("e / f = {0} / {1} = {2}", e, f, e / f));
            specFunc.Pause();
        }
Example #13
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var specFunc = new UtilityForStudy();

            int n = int.Parse(Console.ReadLine());

            Student[] stds = new Student[n];

            for (int i = 0; i < n; i++)
            {
                Student std = new Student(Console.ReadLine().Split(' '));
                int     j   = i - 1;
                for (j = i - 1; j >= 0; j--)
                {
                    if (stds[j].AverageMark > std.AverageMark)
                    {
                        stds[j + 1] = stds[j];
                    }
                    else
                    {
                        break;
                    }
                }
                stds[j + 1] = std;
            }

            int cnt = 3, k = 0;

            do
            {
                Console.WriteLine(stds[k]);
                k++;
                cnt--;
            }while (cnt > 0 || stds[k].AverageMark == stds[k - 1].AverageMark);


            specFunc.Pause();
        }
Example #14
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var specFunc  = new  UtilityForStudy();
            var startTime = DateTime.Now;
            int cnt       = 0;

            for (int i = 1; i <= 1000000000; i++)
            {
                if (IsGoodNumber(i))
                {
                    cnt++;
                }
                if (i % 1000000 == 0)
                {
                    Console.Write(string.Format("Проверено: {0}\r", i));
                }
            }

            var endTime = DateTime.Now;

            Console.WriteLine(string.Format("Количество хороших чисел: {0}\nВремя выполнения: {1}", cnt, endTime - startTime));
            specFunc.Pause();
        }
Example #15
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var         specFunc = new UtilityForStudy();
            DoubleArray list = new DoubleArray(10, 5);
            int         iW, iH;

            list.PlaceMaxElement(out iW, out iH);


            Console.WriteLine(list);
            //Console.WriteLine($"{double.MinValue} {double.MaxValue * -1} {double.MinValue <= double.MaxValue * -1}");
            Console.WriteLine(list.SumOfElements());
            Console.WriteLine(list.SumOfElements(950));
            Console.WriteLine($"Минимальный элемент: {list.MinElement}");
            Console.WriteLine($"Максимальный элемент: {list.MaxElement}:");
            Console.WriteLine(string.Format("Положение по горизонтали: {0}, Положение по вертикали: {1}", iW, iH));
            list.SaveToFile("savebase.pt");
            list.LoadFromFile("savebase.pt");
            Console.WriteLine();
            Console.WriteLine(list);


            specFunc.Pause();
        }
Example #16
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var  specFunc = new  UtilityForStudy();
            char sym;
            int  a, b;

            // Исполнение программы до нажатия символа '0'
            do
            {
                Console.WriteLine("Нажмите\n" +
                                  "0 - Выход;\n" +
                                  "a - Вывести числа от a до b\n" +
                                  "b - Вывести сумму чисел от a до b;");
                sym = Console.ReadKey().KeyChar;
                Console.WriteLine();
                if (sym == 'a' || sym == 'b')
                {
                    specFunc.Print("Введите целое a:\n");
                    a = int.Parse(Console.ReadLine());
                    specFunc.Print("Введите целое b:\n");
                    b = int.Parse(Console.ReadLine());

                    if (sym == 'a')
                    {
                        TaskA(a, b);
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine(string.Format("Sum: {0}", TaskB(a, b)));
                    }
                }
            } while (sym != '0');

            specFunc.Pause();
        }
Example #17
0
        /// <summary>
        /// Точка входа
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var  specFunc  = new UtilityForStudy();
            var  dataGames = new Doubler();
            bool isGame    = true;
            int  cntStep   = 0;

            Console.WriteLine("Здравствуйте, это игра Удвоитель.\n" +
                              "Вам необходимо с помощью действий \"умножения числа на 2\" и " +
                              "\"прибавления на 1\" получить данное число.");

            do
            {
                Console.WriteLine(string.Format("Текущее: {0}, " +
                                                "Необходимое: {1}, Количество шагов {2}:\n",
                                                dataGames.Current, dataGames.Finish, cntStep++));
                Console.WriteLine("Действия:\n" +
                                  "1 - текущее значение увеличить на 1;\n" +
                                  "2 - удвоить текущее значение;\n" +
                                  "3 - перезагрузить игру;\n" +
                                  "0 - выход.\n");
                switch (Console.ReadKey().KeyChar)
                {
                case '1':
                    dataGames.Step(Doubler.Action.Up1);
                    break;

                case '2':
                    dataGames.Step(Doubler.Action.Multy2);
                    break;

                case '3':
                    Console.WriteLine("\n\nВнимание!!!\n" +
                                      "Текущий прогресс будет потерян. " +
                                      "Необходимое значение не будет изменено.\n" +
                                      "Если вы уверены введите текущее значение " +
                                      "и нажмите клавишу Enter.");
                    int Number;
                    int.TryParse(Console.ReadLine(), out Number);
                    if (Number == dataGames.Current)
                    {
                        Console.Clear();
                        Console.WriteLine("Перезагрузка!");
                        dataGames.Step(Doubler.Action.return1);
                        cntStep = 0;
                    }
                    cntStep--;
                    break;

                case '0':
                    isGame = false;
                    break;

                default:
                    cntStep--;
                    break;
                }
                if (dataGames.Current >= dataGames.Finish)
                {
                    if (dataGames.Current == dataGames.Finish)
                    {
                        Console.WriteLine(string.Format("\rВеликолепно! " +
                                                        "Вы достигли необходимого значения. " +
                                                        "Количество шагов: {0}", cntStep));
                    }
                    else
                    {
                        Console.WriteLine("\rК сожалению вы " +
                                          "превысили необходимое значение.");
                    }
                    Console.WriteLine("Хотите сыграть ещё раз?\n" +
                                      "Введите \"Yes\" or \"No\"?");
                    isGame = false;
                    bool isAnswer;

                    do
                    {
                        string answer = Console.ReadLine();
                        isAnswer = false;
                        switch (answer)
                        {
                        case "yes":
                        case "Yes":
                            dataGames = new Doubler();
                            isGame    = true;
                            break;

                        case "no":
                        case "No":
                            break;

                        default:
                            isAnswer = true;
                            break;
                        }
                    } while (isAnswer);
                }

                Console.Clear();
            } while (isGame);
            Console.WriteLine("Пока.");
            specFunc.Pause();
        }