Tugas Matematika terapan saya yang kedua tu disuruh buat program perhitungan matriks pake Pascal… yaps kalau sama ama tugas kamu.. ya tinggal COPAS aja dah… okay!! Cekidot…
program matrik;
uses wincrt;
type data = array[1..5,1..5] of integer;
var
matrikI,matrikII : data;
baris,kolom,pil : integer;
procedure isi;
var
i,j :integer;
begin
writeln(‘Penentuan ORDO MATRIK I’);
write(‘Masukan banyak baris matrik I : ‘);readln(baris);
write(‘Masukan banyak kolom matrik I : ‘);readln(kolom);
for i:=1 to baris do
for j:=1 to kolom do
begin gotoxy(j*10,i*5);
readln(matrikI[i,j]);
end;
clrscr;
writeln(‘Penentuan ORDO MATRIK II’);
write(‘Masukan banyak baris matrik II : ‘);
readln(baris);
write(‘Masukan banyak kolom matrik II : ‘);
readln(kolom);
for i:=1 to baris do
for j:=1 to kolom do
begin gotoxy(j*10,i*5);
readln(matrikII[i,j]);
end;
end;
procedure jumlah(a1,a2 : data);
var
hasil:data;
i,j:integer;
begin
for i:=1 to baris do
for j:=1 to kolom do
begin
hasil[i,j]:=a1[i,j]+a2[i,j];
end;
clrscr;
writeln(‘Hasil Penjumlahan’);
for i:=1 to baris do
for j:=1 to kolom do
begin gotoxy(j*10,i*5);
write(hasil[i,j]);
end;
end;
procedure kurang(a1,a2 : data);
var
hasil: data;
i,j: integer;
begin
for i:=1 to baris do
for j:=1 to kolom do
begin
hasil[i,j]:=a1[i,j]-a2[i,j];
end;
clrscr;
writeln(‘Hasil Pengurangan’);
for i:=1 to baris do
for j:=1 to kolom do
begin gotoxy(j*10,i*5);
write(hasil[i,j]);
end;
end;
procedure kali(a1,a2 : data);
var
hasil:data;
i,j,z:integer;
begin
for i:=1 to baris do
for j:=1 to kolom do
begin
hasil[i,j]:=0;
for z:=1 to baris do
hasil[i,j]:=hasil[i,j]+matrikI[i,z]*matrikII[z,j];
end;
if matrikI[i,z] <> matrikII[z,j] then
begin
clrscr;
writeln(‘maaf data yang anda masukan tidak sesuai prosedur perkalian!’);readln;
end
else
if matrikI[i,z] = matrikII[z,j] then
begin
clrscr;
writeln(‘Hasil perkalian’);
for i:=1 to baris do
for j:=1 to kolom do
begin gotoxy(j*10,i*5);
write(hasil[i,j]);
end;
end;
end;
begin
writeln(‘MENU’);
writeln(‘(1) Penjumlahan Matrik’);
writeln(‘(2) Pengurangan Matrik’);
writeln(‘(3) Perkalian Matrik’);
write(‘Pilihan = ‘);
readln(pil);
clrscr;
case pil of
1 :begin
isi;
jumlah(matrikI,matrikII);
end;
2:begin
isi;
kurang(matrikI,matrikII);
end;
3:begin
isi;
kali(matrikI,matrikII);
end;
end;
end.
Home » Program Pascal » Program Matriks dengan Pascal
{ 0 komentar... read them below or add one }
Posting Komentar