public static ListEntry Multiplication(ListEntry pol_1, ListEntry pol_2) { if (pol_1 != null && pol_2 != null) { // перемножение членов ListEntry ans = new ListEntry(); ListEntry list = ans; while (pol_1 != null) { ListEntry help_pol_2 = pol_2; while (help_pol_2 != null) { list.Next = new ListEntry(pol_1.Degree + help_pol_2.Degree, pol_1.A * help_pol_2.A); list = list.Next; help_pol_2 = help_pol_2.Next; } pol_1 = pol_1.Next; } ans = ans.Next; list = ans; // приведение подобных while (list != null) { ListEntry help_list = list.Next; ListEntry help_list_last = list; while (help_list != null) { if (help_list.Degree == list.Degree) { list.A += help_list.A; help_list_last.Next = help_list.Next; help_list = help_list.Next; } else { help_list_last = help_list_last.Next; help_list = help_list.Next; } } list = list.Next; } // удаление нулевых членов while (ans.A == 0) { ans = ans.Next; } if (ans != null) { list = ans.Next; ListEntry last_list = ans; while (list != null) { if (list.A == 0) { last_list.Next = list.Next; list = list.Next; } else { last_list = list; list = list.Next; } } } return(ans); } else { return(null); } }