pascal为什么?它总在a:array[1..max]of longint; 在]这里报错? 如能回答 谢谢!
constn=10;vara:array[1..max]oflongint;i:longint;//////////////////////////procedureqs...
const n=10;
var a:array[1..max] of longint;
i:longint;
//////////////////////////
procedure qsort(l,r:longint);
var
i,j,m,te:longint;
begin
i:=l;
j:=r;
mid:=a[(l+r)div 2];
repeat
while a[i]<mid do i:=i+1;
while mid<a[j] do j:=j-1;
if i<=j then
begin
te:=a[i];
a[i]=a[j];
a[j]:=te;
i:=i+1;
j:=j-1;
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
//////////////////////////
begin
randomize;
for i:=1 to n do a[i]:=random(30000);
writeln('before');
for i:=1 to n do writeln(a[i]:3);
writeln('sorting...');
qsort(1,max);
for i:=1 to n do writel(a[i]:3)
end. 展开
var a:array[1..max] of longint;
i:longint;
//////////////////////////
procedure qsort(l,r:longint);
var
i,j,m,te:longint;
begin
i:=l;
j:=r;
mid:=a[(l+r)div 2];
repeat
while a[i]<mid do i:=i+1;
while mid<a[j] do j:=j-1;
if i<=j then
begin
te:=a[i];
a[i]=a[j];
a[j]:=te;
i:=i+1;
j:=j-1;
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
//////////////////////////
begin
randomize;
for i:=1 to n do a[i]:=random(30000);
writeln('before');
for i:=1 to n do writeln(a[i]:3);
writeln('sorting...');
qsort(1,max);
for i:=1 to n do writel(a[i]:3)
end. 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询