Помощь - Поиск - Пользователи - Календарь
Полная версия: Операции со списками
Форум «Всё о Паскале» > Современный Паскаль и другие языки > Делфи
Котэ
1)Обеспечение произвольного количества добавленных элементов с клавиатуры (не используя "random" , внести изменения в InitNode)
2) Обеспечить удаление элемента списка по ключу , внести изменения в DeleteNode
3) Организовать операции с двухсвязным списком (переделать в двухсвязный список) , +prev(предыдущий элемент )
Помогите пожалуйста , надо очень срочно ! За ранее большое спасибо !!!!

program Number_LIST;

{$APPTYPE CONSOLE}

uses
SysUtils;

Type
NodePointer=^Node;
Node=Record
s:integer;
next:NodePointer;

end;
Var first:NodePointer;

function InitNode:NodePointer ;
var newNode:NodePointer;
begin
New(newNode);
newNode^.s:=Random(99)+1;
newNode^.next:=NIL;
InitNode:=newNode;
end;

procedure IncludeNode(newNode: NodePointer);
begin
newNode^.next:=first;
first:=newNode;
end;

procedure DeleteNode(k:integer);
var previos, current:Nodepointer;
i :integer;
begin
i:=0;
current:=first;
while current<>NIL do begin
i:=i+1;
if i=k then begin
if first=current then first:=current^.next
else previos^.next:=current^.next;
dispose(current);
break;
end;
previos:=current;
current:=current^.next;
end;
end;

procedure PrintNodeList;
var
p:NodePointer;
begin
writeln;
p:=first;
while p<>NIL do
begin
write(p^.s:3,' ') ;
p:=p^.next;
end;
end;

Var i,m,n:integer;

begin
first:=Nil;
Randomize;
n:=17;
for I := 1 to n do IncludeNode(InitNode);
PrintNodeList;
writeln;
m:=2;
DeleteNode(m);
PrintNodeList;
readln;
end.
nishaknapp
Why not settling on games that is fun and at the same time your earning. Well it'll make suspense because the game is well but dude just try it and it gave me hope while pandemic is real rn. Highest Earthshattering Wins in the History of Online Casino
Это текстовая версия — только основной контент. Для просмотра полной версии этой страницы, пожалуйста, нажмите сюда.