http://virtual-object.narod.ru
 
    Virtual Object :: Programs :: Сортировка динамическим списком
  Download
 
Наша кнопка
Сортировка динамическим списком
{$APPTYPE CONSOLE}

type TPStudent = ^TStudent;
Tstudent = record
 name: string;
 next: TPStudent;
end;
var start,temp,node: TPStudent;
curr: TPStudent;
buf:string;
begin
assign(input,′input.txt′);reset(input);
assign(output,′output.txt′);rewrite(output);
start:=nil;
⁄⁄----------------------------------------
 while not seekeof(input) do
  begin
   readln(buf);
   new(node);
   node^.name:=buf;
   node^.next:=nil;
   curr:=start;
   temp:=nil;
   while (curr<>nil)and(node^.name>curr^.name) do
    begin
     temp:=curr;
     curr:=curr^.next;
    end;
   if temp=nil then
    begin
     node^.next:=start;
     start:=node;
    end else
    begin
     node^.next:=curr;
     temp^.next:=node;
    end;
  end;
⁄⁄----------------------------------------
 curr:=start;
 while curr<>nil do
  begin
   writeln(curr^.name);
   curr:=curr^.next;
  end;
close(input);
close(output);
end.
  JavaScript
  Animation
  Links
 
  Mail
 
 
 

Object © 2004 - 2005. All rights reserved.

 
Сайт создан в системе uCoz