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."); } }
/// <summary> /// Заполнение данных из консоли /// </summary> /// <param name="persons"></param> /// <param name="count"></param> /// <returns></returns> static bool FillQueueFromConcole(ref MyQueue <Person> persons, out int count) { Console.WriteLine("Введите данные:"); string[] phones = Console.ReadLine().Split(' '); if (!int.TryParse(phones[0], out count)) { return(false); } for (int i = 1; i < phones.Length; i++) { Person person = new Person(phones[i]); person.Id = i; persons.enqueue(person); } return(true); }