Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Black;

            Console.WriteLine("\nВводите строки для записи в список (введите 0 для окончания записи)");

            string str;

            do
            {
                str = Console.ReadLine();
                strList.Add(str);

            } while (str != "0");

            strList = strList.SSort(strList);

            Console.WriteLine("\nstrList.SSort = ");

            for (int k = 0; k < strList.Count; k++)
            {
                Console.Write(" " + strList[k]);
            }

            SameLeft();

            Console.WriteLine("\nstrList (после SameLeft) = ");

            for (int k = 0; k <= strList.Count - 1; k++)
            {
                Console.Write(" " + strList[k]);
            }

            string finalStr = ""; int t = 0;

            for (t = 0; t < strList.Count; t++)
            {
                finalStr += strList[t];
            }

            Console.Write("\n\nСлово из одинаковых : {0} ", finalStr);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Сортировка строк в списке по алфавиту
 /// </summary>
 public MyList SSort(MyList a)
 {
     if (_head != null)
     {
         bool ok = true;
         while (ok)
         {
             ok = false;
             for (int i = 0; i < a.Count - 1; i++)
             {
                 for (int j = a.Count - 1; j > i; j--)
                 {
                     if (a[i].CompareTo(a[j]) > 0)
                     {
                         string tmp = a[i];
                         a[i] = a[j];
                         a[j] = tmp;
                         ok = true;
                     }
                 }
             }
         }
         return a;
     }
     else return a;
 }