Berikut akan saya bagikan salah satu contoh program penghitung matriks pada Pascal,, semoga bermanfaat bagi yang memerlukannya.. :)
Source Codenya :
uses crt;
type data=array[1..3,1..3] of integer;
var matI,matII:data;
pil:integer;
procedure isi;
var i,j:integer;
begin
writeln('Penentuan ORDO MATRIK I');writeln;
for i:=1 to 3 do
for j:=1 to 3 do
begin
gotoxy(j*5,i*2+1);
readln(matI[i,j]);
end;
writeln;
writeln('Penentuan ORDO MATRIK II');writeln;
for i:=1 to 3 do
for j:=1 to 3 do
begin
gotoxy(j*5,i*2+9);
readln(matII[i,j]);
end;
clrscr;
end;
procedure jum(a1,a2:data);
var hasil:data;
i,j:integer;
begin
for i:=1 to 3 do
for j:=1 to 3 do
begin
hasil[i,j]:=a1[i,j]+a2[i,j];
end;
writeln;
writeln('Hasil Penjumlahan');
for i:=1 to 3 do
for j:=1 to 3 do
begin gotoxy(j*8,i*4);
write(hasil[i,j]);
end;
readln;
end;
procedure kur(a1,a2:data);
var hasil:data;
i,j:integer;
begin
for i:=1 to 3 do
for j:=1 to 3 do
begin
hasil[i,j]:=a1[i,j]-a2[i,j];
end;
writeln;
writeln('Hasil Pengurangan');
for i:=1 to 3 do
for j:=1 to 3 do
begin gotoxy(j*8,i*4);
write(hasil[i,j]);
end;
readln;
end;
procedure kali(a1,a2:data);
var hasil:data;
i,j,z:integer;
begin
for i:=1 to 3 do
for j:=1 to 3 do
begin
hasil[i,j]:=0;
for z:=1 to 3 do
hasil[i,j]:=hasil[i,j]+matI[i,j]*matII[z,j];
end;
writeln;
writeln('Hasil Perkalian');
for i:=1 to 3 do
for j:=1 to 3 do
begin gotoxy(j*8,i*4);
write(hasil[i,j]);
end;
readln;
end;
procedure tran;
var M:array[1..3,1..3] of integer;
i,j:integer;
begin
clrscr;
writeln('Penentuan ORDO MATRIK');
writeln;
write('Matrik = ');
for i:=1 to 3 do
for j:=1 to 3 do
begin
gotoxy(j*6,i*3+4);
readln(M[i,j]);
end;
begin
clrscr;
writeln('Hasil Transpose');
writeln;
write('Matrik Transpose = ');
for i:=1 to 3 do
for j:=1 to 3 do
begin gotoxy(j*8,i*5);
writeln(M[j,i]);
end;
end;
readln;
end;
begin
repeat
clrscr;
writeln('MENU');
writeln('1. Penjumlahan Matrik');
writeln('2. Pengurangan Matrik');
writeln('3. Perkalian Matrik');
writeln('4. Transpose Matrik');
writeln('5. Keluar');
writeln;
write('Pilihan = ');readln(pil);
clrscr;
case pil of
1:begin
isi;
jum(matI,matII);
end;
2:begin
isi;
kur(matI,matII);
end;
3:begin
isi;
kali(matI,matII);
end;
4:begin
tran;
end;
5:begin
exit;
end;
end;
until pil=5;
end.
kalau ingin download programnya,, silahkan klik (DISINI)
Senin, 08 Desember 2014
Contoh Program Penghitung Matriks pada Pascal
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar