讨论 / 竟然是 90 分!!!!差一点!!!!
夏琦 2012-12-20 21:36:00
点我顶贴 收藏 删除
大家帮忙看看!

var

m:array[1..10000] of string;

a:array[1..10000] of double;

s:string;

t:double;

n,i,j:integer;

begin

readln(n);

for i:=1 to n do

begin

readln(m[i],a[i]);

end;

for i:=1 to n-1 do

begin

for j:=i+1 to n do

begin

if a[i]<a[j] then

begin

t:=a[i];

a[i]:=a[j];

a[j]:=t;

s:=m[i];

m[i]:=m[j];

m[j]:=s;

end;

if a[i]=a[j] then

begin

if length(m[i])<length(m[j]) then

begin

if copy(m[i],1,length(m[i]))<copy(m[j],1,length(m[i])) then

begin

t:=a[i];

a[i]:=a[j];

a[j]:=t;

s:=m[i];

m[i]:=m[j];

m[j]:=s;

end

else

if copy(m[i],1,length(m[j]))<copy(m[j],1,length(m[j])) then

begin

t:=a[i];

a[i]:=a[j];

a[j]:=t;

s:=m[i];

m[i]:=m[j];

m[j]:=s;

end;

end;

end;

end;

end;

for i:=1 to n do

begin

writeln(m[i]);

end;

end.

#1 nxy-2@2012-12-20 21:34:00
回复 删除
var a,b:array[1..5000] of string;

i,j,n:integer;

s:string;

begin

readln(n);

for i:=1 to n do

begin

readln(a[i]);

readln(b[i]);

end;

for i:=1 to n-1 do

for j:=i+1 to n do

if b[i]<b[j] then

begin

s:=b[i];

b[i]:=b[j];

b[j]:=s;

s:=a[i];

a[i]:=a[j];

a[j]:=s;

end

else

if b[i]=b[j] then

if a[i]<a[j] then

begin

s:=b[i];

b[i]:=b[j];

b[j]:=s;

s:=a[i];

a[i]:=a[j];

a[j]:=s;

end;

for i:=1 to n do

writeln(a[i]);

end.

#2 夏琦@2012-12-20 21:35:00
回复 删除
BTK
#3 夏琦@2012-12-20 21:36:00
回复 删除
错误程序,害我
#4 nxy-2@2012-12-20 21:36:00
回复 删除
var a,b:array[1..5000] of string;

i,j,n:integer;

s:string;

begin

readln(n);

for i:=1 to n do

begin

readln(a[i]);

readln(b[i]);

end;

for i:=1 to n-1 do

for j:=i+1 to n do

if b[i]<b[j] then

begin

s:=b[i];

b[i]:=b[j];

b[j]:=s;

s:=a[i];

a[i]:=a[j];

a[j]:=s;

end

else

if b[i]=b[j] then

if a[i]<a[j] then

begin

s:=b[i];

b[i]:=b[j];

b[j]:=s;

s:=a[i];

a[i]:=a[j];

a[j]:=s;

end;

for i:=1 to n do

writeln(a[i]);

end.

查看更多回复
提交回复