- 奖学金
- 2014-07-28 16:56:40 @
var q,n,w,x:integer;
a,b,c,d,z:array[1..300]of integer;
begin
readln(n);
for q:=1 to n do begin
d[q]:=q;
readln(a[q],b[q],c[q]);
z[q]:=a[q]+b[q]+c[q];
end;
for q:=1 to n-1 do begin
for w:=q to n do
if (z[q]<z[w])and(q<>w)then begin
x:=z[q];
z[q]:=z[w];
z[w]:=x;
x:=d[q];
d[q]:=d[w];
d[w]:=x;
end;
end;
for q:=1 to n-1 do begin
for w:=1 to q do
if (z[q]=z[w])and(q<>w)and(d[q]<d[w])then begin
x:=d[q];
d[q]:=d[w];
d[w]:=x;
end;
end;
for q:=1 to 5 do writeln(d[q],' ',z[q]);
readln;readln;
end.
2 条评论
-
hahayang LV 10 @ 2017-07-11 14:17:07
呵呵
type student=record p,ch,ma,en,al:integer end; var a:array[1..300] of student; n,i,j:integer; t:student; begin readln(n); for i:=1 to n do begin readln(a[i].ch,a[i].ma,a[i].en); a[i].p:=i; a[i].al:=a[i].ch+a[i].ma+a[i].en end; for i:=1 to n-1 do for j:=i+1 to n do if (a[i].al<a[j].al) or ((a[i].al=a[j].al) and (a[i].ch<a[j].ch)) then begin t:=a[i]; a[i]:=a[j]; a[j]:=t end; for i:=1 to 5 do writeln(a[i].p,' ',a[i].al) end.
-
2014-08-13 18:52:00@
你这是抄别人的吧。。。
- 1