讨论 / 第一个pascal语言的题解哟!顶一下吧!
清晨芦竹 2017-02-11 15:25:02
点我顶贴 收藏 删除
看看啦。我这可是又臭又长哦!

Program money;

var

a,f:array[1..1000] of longint;

b:array[1..1000] of longint;

c:array[1..1000] of longint;

d:array[1..1000] of longint;

i,j,n,s,t,v:longint;

begin

readln(n);

for i:=1 to n do

begin

readln(b[i],c[i],d[i]);

a[i]:=i;

f[i]:=b[i]+c[i]+d[i];

end;

for i:=1 to n-1 do

for j:=i+1 to n do

begin

if f[i]<f[j] then

begin

t:=a[i]; a[i]:=a[j]; a[j]:=t;

t:=f[i]; f[i]:=f[j]; f[j]:=t;

t:=b[i]; b[i]:=b[j]; b[j]:=t;

end;

if f[i]=f[j] then

begin

if b[i]<b[j] then

begin

t:=a[i]; a[i]:=a[j]; a[j]:=t;

t:=f[i]; f[i]:=f[j]; f[j]:=t;

t:=b[i]; b[i]:=b[j]; b[j]:=t;

end;

end;

if (f[i]=f[j]) and (b[i]=b[j]) then

begin

if a[i]>a[j] then

begin

t:=a[i]; a[i]:=a[j]; a[j]:=t;

t:=f[i]; f[i]:=f[j]; f[j]:=t;

t:=b[i]; b[i]:=b[j]; b[j]:=t;

end;

end;

end;

for i:=1 to 5 do

begin

writeln(a[i],' ',f[i]);

end;

end.

查看更多回复
提交回复