Example #1
0
        static void Main(string[] args)
        {
            bool           exit = true;
            ConsoleKeyInfo key;

            while (exit)
            {
                Console.Clear();
                Console.WriteLine("Выберите задание");
                key = Console.ReadKey();
                Console.WriteLine();
                switch (key.KeyChar)
                {
                case '1':
                {
                    Console.WriteLine("Введите нужное количество точек:");
                    point[] point_arr = new point[Convert.ToInt32(Console.ReadLine())];
                    for (int i = 0; i < point_arr.Length; i++)
                    {
                        Console.WriteLine("Точка {0}", i + 1);
                        Console.Write("x="); point_arr[i].x_coord = Convert.ToDouble(Console.ReadLine());
                        Console.Write("y="); point_arr[i].y_coord = Convert.ToDouble(Console.ReadLine());
                    }
                    TaskMethods.MaxPointsLenght(point_arr);
                    Console.ReadKey();
                    break;
                }

                case '2':
                {
                    Console.WriteLine("Сколько слов вы хотите ввести?");
                    string[] arr_words = new string[Convert.ToInt32(Console.ReadLine())];
                    for (int i = 0; i < arr_words.Length; i++)
                    {
                        Console.Write("Введите слово {0}:", i + 1);
                        arr_words[i] = Console.ReadLine();
                    }
                    int Count;
                    Console.WriteLine("Слово с наибольшим количеством гласных {0}, их количество {1}", TaskMethods.MaxVowelCount(arr_words, out Count), Count);
                    Console.ReadKey();
                    break;
                }

                case '3':
                {
                    Console.WriteLine("Cколько чисел вы хотите ввести?");
                    Int64[] arr_numbers = new Int64[Convert.ToInt32(Console.ReadLine())];
                    for (int i = 0; i < arr_numbers.Length; i++)
                    {
                        Console.Write("Введите число {0}:", i + 1);
                        arr_numbers[i] = Convert.ToInt64(Console.ReadLine());
                    }
                    for (int i = 0; i < arr_numbers.Length; i++)
                    {
                        Console.WriteLine("Число {0} на позиции {1} имеет сумму чисел {2}", arr_numbers[i], i + 1, Task2Var.SumNumbers(arr_numbers[i]));
                    }
                    Console.ReadKey();
                    break;
                }

                case '4':
                {
                    Console.WriteLine("Введите m, n, k, a");
                    Console.WriteLine("Результат функции  {0}", TaskMethods.SolveFunction(Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), Convert.ToDouble(Console.ReadLine()), Convert.ToInt32(Console.ReadLine())));
                    Console.ReadKey();
                    break;
                }

                case '5':
                {
                    double[] points  = new double[4];
                    string   letters = "abcd";
                    for (int i = 0; i < points.Length; i++)
                    {
                        Console.WriteLine("Введите длину отрезка {0}", letters[i]);
                        points[i] = Convert.ToDouble(Console.ReadLine());
                    }
                    TaskMethods.TriangleSquare(points);
                    Console.ReadKey();
                    break;
                }

                case '6':
                {
                    Console.WriteLine("Введите число, факториал которого вы хотите найти:");
                    Console.WriteLine("Результат - {0}", TaskMethods.fact(Convert.ToInt32(Console.ReadLine())));
                    Console.ReadKey();
                    break;
                }

                default:

                    break;
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            bool           exit = true;
            ConsoleKeyInfo key;

            while (exit)
            {
                Console.Clear();
                Console.WriteLine("Выберите задание");
                key = Console.ReadKey();
                Console.WriteLine();
                switch (key.KeyChar)
                {
                case '1':
                {
                    Console.WriteLine("Введите ваш массив элементов");
                    string rr = Console.ReadLine();
                    bool   ok = true;
                    for (int i = 0; i < rr.Length; i++)
                    {
                        if (!char.IsLetter(rr[i]))
                        {
                            ok = false;
                        }
                    }
                    if (ok)
                    {
                        char[] arr = new char[rr.Length];
                        for (int i = 0; i < arr.Length; i++)
                        {
                            arr[i] = rr[i];
                        }
                        rr = Task2Var.ReWorkRusandEngLetters(arr);
                        Console.WriteLine("Результат:\n{0}", rr);
                    }
                    else
                    {
                        Console.WriteLine("Ваш массив состоит не только из букв");
                    }
                    Console.ReadKey();
                    break;
                }

                case '2':
                {
                    Console.WriteLine("Введите слово к которому хотите добавить не:");
                    string word = Console.ReadLine();
                    Console.WriteLine("Результат:\n{0}", Task2Var.AppendNe(word));
                    Console.ReadKey();
                    break;
                }

                case '3':
                {
                    Console.WriteLine("Введите строку в которой хотите убрать лишние пробелы");
                    string word = Console.ReadLine();
                    Console.WriteLine("\n{0}", Task2Var.RemoveSpaces(word));
                    Console.ReadKey();
                    break;
                }

                case '4':
                {
                    Task2Var.WorkWithHashSymbol(Console.ReadLine());
                    Console.ReadLine();
                    break;
                }

                case '5':
                {
                    Console.WriteLine("Введите число, сумму которого вы хтите посчитать");
                    Int64 num = Convert.ToInt64(Console.ReadLine());
                    Console.WriteLine("Сумма цифр данного числа: {0}", Task2Var.SumNumbers(num));
                    Console.ReadKey();
                    break;
                }

                case '6':
                {
                    Console.WriteLine("Введите слово для шифровки");
                    Console.WriteLine("Зашифрованное слово - {0}", Task2Var.CryptAlphabet(Console.ReadLine()));

                    Console.ReadKey();
                    break;
                }

                default:

                    break;
                }
            }
        }