会做的话给跪了,大神们来看看吧
pascal吧
全部回复
仅看楼主
level 1

将两个顺序存储的有序线性表
S1
和
S2
合并,使得合并后的线性表
S
仍然有序。(升序)
2013年11月27日 03点11分 1
level 8
归并排序的简单应用[汗]
    ╯     ╰
    ●      ●
    "    ^    "
2013年11月27日 07点11分 2
level 12
百度-归并排序
2013年11月28日 04点11分 3
level 12
随手写了个程序,略长。。
program tguibing;
type point=^node;
node=record
data:longint;
next:point;
end;
var head1,head2,head3,p,q:point;
i,j:longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a)
else exit(b);
end;
function min(a,b:longint):longint;
begin
if a<b then exit(a)
else exit(b);
end;
procedure init;
var i,j,t,n:longint;
p,q:point;
begin
readln(n);
new(p);head1:=p;read(p^.data);
for i:=2 to n do
begin
new(q);
p^.next:=q;
p:=q;
read(p^.data);
end;
readln;
p^.next:=nil;
readln(n);
new(p);head2:=p;read(p^.data);
for i:=2 to n do
begin
new(q);
p^.next:=q;
p:=q;
read(p^.data);
end;
p^.next:=nil;
end;
procedure sort(head1,head2:point;var head3:point);
var t1,t2:longint;
p,q,r,s,tt:point;
begin
p:=head1;
q:=head2;
new(head3);r:=head3;
while not ((p=nil)and(q=nil)) do
begin
if p=nil then t1:=maxlongint else t1:=p^.data;
if q=nil then t2:=maxlongint else t2:=q^.data;
new(s);
tt:=r;
r^.data:=min(t1,t2);
r^.next:=s;
r:=s;
if t1<=t2 then p:=p^.next else q:=q^.next;
end;
r:=tt;
dispose(r^.next);
r^.next:=nil;
end;
procedure print(head:point);
var p:point;
begin
p:=head;write(p^.data,' ');p:=p^.next;
while (p<>nil) and (p<>head) do
begin
write(p^.data,' ');
p:=p^.next;
end;
end;
Begin {main}
assign(input,'input.txt');
reset(input);
init;
sort(head1,head2,head3);
print(head3);
close(input);
End.
2013年11月28日 04点11分 4
好厉害啊,我是初学者,不怎么懂,请问你们是怎么学习的……
2013年11月28日 05点11分
回复 跳动的汤圆 :我们老师都不算很好的,但是我都是自学,百度各种东西,学算法神马的
2013年11月28日 14点11分
回复 zty61211 :我运行了之后没有结果,但是我也看不出哪里出错了,请问你可以帮我看看还可以按照题目的意思修改一下吗
2013年11月29日 07点11分
回复 跳动的汤圆 :有用文件么
2013年11月29日 10点11分
level 12
或许我理解错楼主意思了。。
楼主是不是只要数组的?
2013年11月30日 10点11分 6
1