Example #1
0
        static void Main()
        {
            MyQueue <char> q = new MyQueue <char>(1);

            string str = " AB an radar na BA ";

            for (int i = 0; i < str.Length; i++)
            {
                q.enqueue(str.ToCharArray()[i]);
            }

            bool simetric = false;
            int  j        = q.Length - 1;

            while (j != 0 & (simetric = (str.ToCharArray()[j--] == q.dequeue())))
            {
                ;
            }
            if (simetric)
            {
                Console.WriteLine("The string \"" + str + "\" is simetric.");
            }
            else
            {
                Console.WriteLine("The string \"" + str + "\" is not simetric.");
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            MyQueue <Person> persons = new MyQueue <Person>();

            int  count     = 0;
            bool isCorrect = false;

            while (!isCorrect)
            {
                try
                {
                    //Заполнение данных
                    isCorrect = FillQueueFromConcole(ref persons, out count);

                    //Вывод данных
                    string output = "";
                    for (int i = 0; i < count; i++)
                    {
                        output += persons.dequeue().PhoneNumber + " ";
                    }
                    Console.Write(output);
                }
                catch (Exception ex)
                {
                    isCorrect = false;
                    Console.WriteLine(ex.Message);
                }
                if (!isCorrect)
                {
                    Console.WriteLine("Вы хотите ввести данные еще раз?(y/n)");

                    if (Console.ReadLine() != "y")
                    {
                        return;
                    }
                }
            }
            Console.ReadKey();
        }