Program Pascal : Menukar Isi Array

Program tukar;
uses wincrt;
type tabint = array[1..100]of integer;

procedure balik_elemen(var a:tabint; n:integer);
var i,tmp,j:integer;
begin
j:=n;
for i:=1 to (n div 2) do
    begin
    tmp:=a[i];
    a[i]:=a[j];
    a[j]:=tmp;
    j:=j-1;
    end
end;

var T:tabint;
    i,n:integer;
begin
write('Masukan batas = ');readln(n);
for i:=1 to n do
    begin
    write(i,' = ');readln(T[i]);
    end;
balik_elemen(T,n);
for i:=1 to n do
    begin
    writeln(T[i]);
    end;
end.

0 comments:

Komentar