uses crt;
type temp=record
name:string;
tm:real;
end;
var x:array[1..100] of temp;
i,j,n,imin:integer;
sr:real;
tmp:temp;
begin
ClrScr;
repeat
Write('n=');
Readln(n);
until n in [1..100];
for i:=1 to n do
with x[i] do
begin
Write(' Name: ');
Readln(name);
Write(' Temp: ');
Readln(tm);
end;
Writeln('-------------------');
Writeln('| Name | Temp |');
Writeln('-------------------');
for i:=1 to n do
Writeln('|',x[i].name:8,'|',x[i].tm:8:1,'|');
Writeln('-------------------');
for i:=1 to n-1 do
begin
imin:=i;
for j:=i+1 to n do
if x[j].tm>x[imin].tm then
imin:=j;
if imin<>i then
begin
tmp:=x[i];
x[i]:=x[imin];
x[imin]:=tmp;
end;
end;
Writeln(' Sort: ');
Writeln('-------------------');
Writeln('| Name | Temp |');
Writeln('-------------------');
for i:=1 to n do
Writeln('|',x[i].name:8,'|',x[i].tm:8:1,'|');
Writeln('-------------------');
Readln;
end.