Skrip Program Matrix – Pascal

Ini skrip program pascal sederhana untuk membuat matrix statis.

uses wincrt;
var
larik: Array[1..12,1..12] of integer;
i, j:integer;

begin 
for i:= 1 to 2 do
begin
for j:=1 to 2 do
begin
write('Elemen(',i,',',j,') = '); readln(larik[i,j]);
end;
writeln;
end;

for i:= 1 to 2 do
begin
for j:=1 to 2 do
begin
writeln('[',i,',',j,'] = ',larik[i,j]);
end;
writeln;
end;
writeln('created by retnodn');
end.

Yang ini skrip program pascal sederhana untuk membuat matrix dinamis.

uses wincrt;
var
i,j,ray:Array[1..10,1..10] of integer;
baris,kolom:integer;

begin
write('jumlah baris : ');readln(baris);
write('jumlah kolom : ');readln(kolom);

for baris:=1 to baris do
for kolom:=1 to kolom do
begin
write('[',baris,',',kolom,'] = ');readln(ray[baris,kolom]);
end;

writeln;
writeln('Matrix yang terbentuk adalah : ');
for baris:=1 to baris do
begin
for kolom:=1 to kolom do
begin
write(ray[baris,kolom]);
write(' ');

end;
writeln;
end;
writeln('created by retnodn');
end.

Sedangkan yang ini adalah skrip program pascal sederhana untuk menjalankan operasi pertambahan pada kedua matrix dinamis:

uses wincrt;
var
i,j,r:Array[1..10,1..10] of integer;
m,n,p:array[1..10,1..10]of integer;
a,b,hasil: array[1..20,1..20]of integer;
baris,kolom,baris2,kolom2:integer;

begin
writeln('----- Masukkan Matrix R -----');
write('jumlah baris : ');readln(baris);
write('jumlah kolom : ');readln(kolom);

for baris:=1 to baris do
for kolom:=1 to kolom do
begin
write('[',baris,',',kolom,'] = ');readln(R[baris,kolom]);
end;
writeln('----- Masukkan Matrix P -----');
write('jumlah baris : ');readln(baris);
write('jumlah kolom : ');readln(kolom);

for baris:=1 to baris do
for kolom:=1 to kolom do
begin
write('[',baris,',',kolom,'] = ');readln(P[baris,kolom]);
end;

writeln;

{------------------------- TAMPILKAN ------------------------}
{------------------------------------------------------------}
for baris:=1 to baris do
begin
for kolom:=1 to kolom do
begin
write(R[baris,kolom]);
write(' ');

end;
writeln;
end;
writeln('ditambah dengan : ');
for baris:=1 to baris do
begin
for kolom:=1 to kolom do
begin
write(P[baris,kolom]);
write(' ');

end;
writeln;
end;
writeln('menjadi : ');

for kolom:=1 to kolom do
begin
for baris:=1 to baris do
begin
hasil[baris,kolom]:=R[baris,kolom] + P[baris,kolom];
end;
end;
for baris:=1 to baris do
begin
for kolom:=1 to kolom do
begin
write(hasil[baris,kolom]);
write(' ');
end;
writeln;
end;
writeln('created by retnodn');
end.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s