标签:
type st=record ch,ma,en,nu,sum:longint; end; var a:array[1..100000] of st; n,i,j:longint; t:st; begin readln(n); for i:=1 to n do begin a[i].nu:=i; readln(a[i].ch,a[i].ma,a[i].en); a[i].sum:=a[i].ch+a[i].ma+a[i].en; end; for i:=1 to n-1 do for j:=1 to n-i do begin if (a[j].sum<a[j+1].sum) then begin t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end; if (a[j].sum=a[j+1].sum) then if a[j].ch<a[j+1].ch then begin t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end; if (a[j].sum=a[j+1].sum)and(a[j].ch=a[j+1].ch) then if a[j].nu>a[j+1].nu then begin t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t; end; end; for i:=1 to 5 do writeln(a[i].nu,‘ ‘,a[i].sum); end.
标签:
原文地址:http://www.cnblogs.com/yangqingli/p/4716342.html