//сумма public static void Summ(Spisok str1) { string StrSum = ""; for (int i = 0; i < str1.Count(); i++) { StrSum += str1.Elements(i); } Console.WriteLine("Весь список - " + StrSum); }
//Удаление заданного эл-та списка public static void DeleteElement(this Spisok str1) { Console.WriteLine("Введите элемент, который нужно удалить"); string delete = Console.ReadLine(); for (int i = 0; i < str1.Count(); i++) { string elem = str1.Elements(i); if (delete == elem) { str1.RemoveElem(i); } } }
//разница между max и min эл-тами списка public static void Difference(Spisok str1) { int max = 0, min = 999; for (int i = 0; i < str1.Count(); i++) { string oop = str1.Elements(i); if (oop.Length > max) { max = oop.Length; } if (oop.Length < min) { min = oop.Length; } } int diff = max - min; Console.WriteLine("Разница между max и min эл-тами - " + diff); }
static void Main(string[] args) { Spisok.Owner i = new Spisok.Owner(); Console.WriteLine(i.id + " " + i.name + " " + i.organization); Spisok.Date time = new Spisok.Date(); Console.WriteLine(time.date); Spisok str1 = new Spisok(); str1.AddElem("Врач"); str1.AddElem("Программист"); str1.AddElem("Учитель"); str1.AddElem("Дизайнер"); Console.WriteLine("Весь список:"); str1.Show(); Console.WriteLine("Удаление элемента из начала списка"); str1 = str1--; str1.Show(); Console.WriteLine("Проверка, пустой ли список"); if (str1) { Console.WriteLine("Список пустой"); } else { Console.WriteLine("Список не является пустым"); } Spisok str2 = new Spisok(); str2.AddElem("Журналист"); str2.AddElem("Тренер"); str2.AddElem("Дворник"); Console.WriteLine("Проверка на равенство: "); bool equal = str1 == str2; if (equal) { Console.WriteLine("Списки равны"); } else { Console.WriteLine("Списки не равны"); } Console.WriteLine("Объединение 2-х списков"); str1 = str1 + str2; str1.Show(); StatisticOperation.NumberOfElements(str1); StatisticOperation.Summ(str1); StatisticOperation.Difference(str1); string str3 = "Blala 78 lala 45 lolo 8"; str3.LastNumber(); str1.DeleteElement(); Console.WriteLine("Удаление заданного эл-та: "); str1.Show(); Console.ReadKey(); }
//кол-во эл-тов списка public static void NumberOfElements(Spisok str1) { int x = str1.Count(); Console.WriteLine("Количество эл-тов в списке - " + x); }