讨论 / 冒泡都过了
NEW WORLD 2014-05-18 18:52:25
点我顶贴 收藏 删除
var

n,i,j,t:longint;

s:real;

a,b:array[1..900]of longint;

begin

readln(n);

for i:=1 to n do

begin

read(a[i]);

b[i]:=i;

end;

for i:=1 to n-1 do

for j:=i+1 to n do

if a[i]>a[j] then

begin

t:=a[i];

a[i]:=a[j];

a[j]:=t;

t:=b[i];

b[i]:=b[j];

b[j]:=t;

end

else if (a[i]=a[j])and(b[i]>b[j]) then

begin

t:=a[i];

a[i]:=a[j];

a[j]:=t;

t:=b[i];

b[i]:=b[j];

b[j]:=t;

end;

s:=0;

for i:= n-1 downto 1 do

s:=s+a[i]*(n-i);

s:=s/n;

for i:=1 to n do

write(b[i],' ');

writeln;

writeln(s:0:2);

end.

#1 NEW WORLD@2014-05-18 18:57:50
回复 删除
排队接水
查看更多回复
提交回复