From f589771843a422686d0e1af4d7b1707cc13d7cdd Mon Sep 17 00:00:00 2001 From: volkovva Date: Sat, 23 May 2026 16:12:52 +0300 Subject: [PATCH] =?UTF-8?q?=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=8F=D0=B2=D0=BD=D1=83=D1=8E=20=D1=81=D0=BE=D1=80=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D1=83=20=D0=B8=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=87?= =?UTF-8?q?=D0=B5=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VolkovVA/cod.py | 58 +++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/VolkovVA/cod.py b/VolkovVA/cod.py index eb77941..1bdb743 100644 --- a/VolkovVA/cod.py +++ b/VolkovVA/cod.py @@ -12,45 +12,51 @@ def ll_insert(head, name, phone): if current['name'] == name: current['phone'] = phone return head + if current['next'] is None: + break current = current['next'] - - new_node['next'] = head - return new_node + current['next'] = new_node + return head def ll_find(head, name): current = head while current is not None: - if current['name']==name: + if current['name'] == name: return current['phone'] - current=current['next'] - return None - - + current = current['next'] + return None + + def ll_delete(head, name): if head is None: return None - if head['name']==name: + if head['name'] == name: return head['next'] - current = head + current = head while current['next'] is not None: if current['next']['name'] == name: - current['next']==current['next']['next'] + current['next'] = current['next']['next'] return head - - -def ll_list_all(head): - record=[] - current=head - while current is not None: - record.append(current['name'], current['phone']) - current=current['next'] - record.sort(key=lambda x: x[0]) - return record + current = current['next'] + return head - - - - - + +def sort_records(lst): + n = len(lst) + for i in range(n): + for j in range(0, n-i-1): + if lst[j][0] > lst[j + 1][0]: + lst[j], lst[j + 1] = lst[j + 1], lst[j] + return lst + + +def ll_list_all(head): + record = [] + current = head + while current is not None: + record += [(current['name'], current['phone'])] + current = current['next'] + res = sort_records(record) + return res \ No newline at end of file