题目: |
program nbcz09_2;
var a,work:array[1..100] of integer;
i,j,x,d,max:integer;
begin
readln(max);
for i:=1 to max do begin
read(a[i]); work[i]:=a[i];
end;
d:=max div 2;
while d>=1 do begin
for i:=d+1 to max do begin
x:=work[i];
j:=i-d;
while (j>0) and (x<work[j]) do begin
work[j+d]:=work[j];
dec(j,d);
end;
work[j+d]:=x;
end;
d:=d div 2;
end;
for i:= max downto 1 do
if a[i]=work[i] then write('1')
else write('0');
writeln;
end.
输入8
71 88 149 32 66 90 144 99 输出:01000000
|