您的位置:首页 > 其它

足球联赛

2015-11-01 14:16 267 查看


思路:极简单的一题。先读入,再计算每队得分。快排一次找出得分最多的队伍,再把队伍按从小到大输出即可。

其实不快排也可以,

program t1;
type
paiming=record
xh,fs:longint;
end;
var n,i,j:longint;
s:array[1..50,1..50]of char;
a:array[1..50]of paiming;
procedure sort(l,r: longint);
var
i,j,x: longint;
y:paiming;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2].fs;
repeat
while a[i].fs>x do
inc(i);
while x>a[j].fs do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
procedure kp(l,r: longint);
var
i,j,x: longint;
y:paiming;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2].xh;
repeat
while a[i].xh<x do
inc(i);
while x<a[j].xh do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
kp(l,j);
if i<r then
kp(i,r);
end;
procedure open;
begin
assign(input,'soccer.in');
assign(output,'soccer.out');
reset(input);
rewrite(output);
end;
procedure guanbi;
begin
close(input);
close(output);
end;
begin
open;
readln(n);
for i:=1 to n do a[i].xh:=i;
for i:=1 to n do a[i].fs:=0;
for i:=1 to n do
begin
for j:=1 to n do read(s[i,j]);
readln;
end;
for i:=1 to n do
for j:=1 to n do
begin
if s[i,j]='W' then inc(a[i].fs,3);
if s[i,j]='D' then
begin
inc(a[i].fs);
inc(a[j].fs);
end;
if s[i,j]='L' then inc(a[j].fs,3);
end;
sort(1,n);
for i:=1 to n do
if a[i].fs<>a[i+1].fs then
begin
if i=1 then
writeln(a[i].xh)
else
begin
kp(1,i);
for j:=1 to i do write(a[j].xh,' ');
writeln;
end;
break;
end;
//for i:=1 to n do writeln(a[i].xh,' ',a[i].fs,' ');
guanbi;
end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: