program sigsag;
uses wincrt;
type
T=array [1..100] of integer;
procedure zigzag(a,b:T;n,m,p:integer; var c:T);
var
q,i,x:integer;
begin
p:=n+m;
x:=0;
if n<m then
begin
for i:= 1 to (n+n) do
begin
if i mod 2 <> 0 then
begin
c[i]:=a[i-x];
x:=x+1;
end;
end;
end
else
c[i]:=b[i+1];
end;
var
a,b,c:T;
i,n,m,p:integer;
begin
write('masukan jumlah array tabel ke 1 = ');read(n);
for i:=1 to n do
begin
write('masukan bilangan ke ',i,' = ');read(a[i]);
end;
writeln;
write('masukan jumlah array tabel ke 2 = ');read(m);
for i:=1 to m do
begin
write('masukan bilangan ke ',i,' = ');read(b[i]);
end;
writeln;
p:=n+m;
zigzag(a,b,n,m,p,c);
writeln('jadi tabel setelah disisipkan adalah');
writeln;
for i:= 1 to p do
write(c[i],' ');
end.
uses wincrt;
type
T=array [1..100] of integer;
procedure zigzag(a,b:T;n,m,p:integer; var c:T);
var
q,i,x:integer;
begin
p:=n+m;
x:=0;
if n<m then
begin
for i:= 1 to (n+n) do
begin
if i mod 2 <> 0 then
begin
c[i]:=a[i-x];
x:=x+1;
end;
end;
end
else
c[i]:=b[i+1];
end;
var
a,b,c:T;
i,n,m,p:integer;
begin
write('masukan jumlah array tabel ke 1 = ');read(n);
for i:=1 to n do
begin
write('masukan bilangan ke ',i,' = ');read(a[i]);
end;
writeln;
write('masukan jumlah array tabel ke 2 = ');read(m);
for i:=1 to m do
begin
write('masukan bilangan ke ',i,' = ');read(b[i]);
end;
writeln;
p:=n+m;
zigzag(a,b,n,m,p,c);
writeln('jadi tabel setelah disisipkan adalah');
writeln;
for i:= 1 to p do
write(c[i],' ');
end.
No comments:
Post a Comment