Popular Post

Posted by : Unknown Selasa, 19 Januari 2010

Belajar Membuat Website n' Dapetin penghasilan. klik :





program Matriks;
uses crt;
label awal;
var mat_A,mat_B,mat_C:array[1..10,1..10] of integer;
ordo_x,ordo_y,ordo_xi,ordo_yi:integer;
x,y,w,z,koor_brs:integer;
pil,jawab:char;

procedure menu;
begin
writeln('DAFTAR MENU');
writeln('1. Penjumlahan Matriks');
writeln('2. Pengurangan matriks');
writeln('3. Perkalian Matriks');
writeln('4. Transpos Matriks');
writeln;
end;

procedure penjumlahan;
begin
clrscr;
writeln(' PENJUMLAHAN MATRIKS ');
writeln('----------------------------------');
writeln;
write('Tentukan banyaknya baris matriks A : ');readln(ordo_x);
write('Tentukan banyaknya kolom matriks A : '); readln(ordo_y);
writeln('Ukuran Matriks A (',ordo_x,'x',ordo_y,')');
writeln;
writeln('Input matriks A : ');
for x:=1 to ordo_x do
begin
koor_brs:=wherey;
for y:=1 to ordo_y do
begin
gotoxy(y*5,koor_brs);
read(mat_A[x,y]);
end;
end;
writeln;
writeln;
write('tentukan banyaknya baris matriks B : ');readln(ordo_xi);
write('tentukan banyaknya kolom matriks B : ');readln(ordo_yi);
writeln('Ukuran Matriks B (',ordo_xi,'x',ordo_yi,')');
writeln;
writeln('Input matriks :');
for x:=1 to ordo_xi do
begin
koor_brs:=wherey;
for y:=1 to ordo_yi do
begin
gotoxy(y*5,koor_brs);
read(mat_B[x,y]);
end;
end;
writeln;
writeln;

if ordo_x=ordo_xi then
begin
if ordo_y=ordo_yi then
begin
writeln('Hasil penjumlahan matriks A+B = ');
for x:=1 to ordo_x do
begin
for y:=1 to ordo_yi do
begin
mat_C[x,y]:=mat_A[x,y]+mat_B[x,y];
write(mat_C[x,y]:5);
end;
writeln;
readln;
end;
end else
end else
begin
writeln('Matriks tidak bisa dijumlahkan karena Ukuran (ordo) matriks A dan B tidak sesuai');
readln
end;
end;

procedure pengurangan;
begin
clrscr;
writeln(' PENGURANGAN MATRIKS ');
writeln('----------------------------------');
writeln;
write('Tentukan baris matriks A : ');readln(ordo_x);
write('Tentukan kolom matriks A : '); readln(ordo_y);
writeln('Ukuran Matriks A (',ordo_x,'x',ordo_y,')');
writeln;
writeln('Input matriks A : ');
for x:=1 to ordo_x do
begin
koor_brs:=wherey;
for y:=1 to ordo_y do
begin
gotoxy(y*5,koor_brs);
read(mat_A[x,y]);
end;
end;
writeln;
writeln;
write('masukkan baris matriks B : ');readln(ordo_xi);
write('masukkan kolom matriks B : ');readln(ordo_yi);
writeln('Ukuran Matriks B (',ordo_xi,'x',ordo_yi,')');
writeln;
writeln('Input matriks :');
for x:=1 to ordo_xi do
begin
koor_brs:=wherey;
for y:=1 to ordo_yi do
begin
gotoxy(y*5,koor_brs);
read(mat_B[x,y]);
end;
end;
writeln;
writeln;
if ordo_x=ordo_xi then
begin
if ordo_y=ordo_yi then
begin
writeln('Hasil pengurangan matriks A-B = ');
for x:=1 to ordo_x do
begin
for y:=1 to ordo_yi do
begin
mat_C[x,y]:=mat_A[x,y]-mat_B[x,y];
write(mat_C[x,y]:5);
end;
writeln;
readln;
end;
end else
end else
begin
writeln('Matriks tidak bisa dikurangkan karena ordo matriks A dan B tidak sesuai');
readln;
end;
end;

procedure perkalian;
begin
clrscr;
writeln(' PERKALIAN MATRIKS ');
writeln('----------------------------------');
writeln;
write('Tentukan baris matriks A : ');readln(ordo_x);
write('Tentukan kolom matriks A : '); readln(ordo_y);
writeln('Ukuran Matriks A (',ordo_x,'x',ordo_y,')');
writeln;
writeln('Input matriks A : ');
for x:=1 to ordo_x do
begin
koor_brs:=wherey;
for y:=1 to ordo_y do
begin
gotoxy(y*5,koor_brs);
read(mat_A[x,y]);
end;
end;
writeln;
writeln;
write('masukkan baris matriks B : ');readln(ordo_xi);
write('masukkan kolom matriks B : ');readln(ordo_yi);
writeln('Ukuran Matriks B (',ordo_xi,'x',ordo_yi,')');
writeln;
writeln('Input matriks :');
for x:=1 to ordo_xi do
begin
koor_brs:=wherey;
for y:=1 to ordo_yi do
begin
gotoxy(y*5,koor_brs);
read(mat_B[x,y]);
end;
end;
writeln;
writeln;
if ordo_y=ordo_xi then
begin
writeln('Hasil perkalian matriks A*B = ');
for x:=1 to ordo_x do
begin
for y:=1 to ordo_yi do
begin
mat_c[x,y]:=0;
for z:=1 TO ORDO_yi do
mat_C[x,y]:=mat_C[x,y]+mat_A[x,z]*mat_B[z,y];
write(mat_C[x,y]:5);
end;
writeln;
readln;
end;
end else
begin
writeln('Matriks tidak bisa dikalikan karena ordo matriks A dan B tidak sesuai');
readln;
end;
end;

procedure transpos;
BEGIN
clrscr;
writeln(' TRANSPOS MATRIKS ');
writeln('----------------------------------');
writeln;
write('Tentukan baris matriks A : ');readln(ordo_x);
write('Tentukan kolom matriks A : '); readln(ordo_y);
writeln('Ukuran Matriks A (',ordo_x,'x',ordo_y,')');
writeln;
writeln('Input matriks A : ');
for x:=1 to ordo_x do
begin
koor_brs:=wherey;
for y:=1 to ordo_y do
begin
gotoxy(y*5,koor_brs);
read(mat_A[x,y]);
end;
end;
writeln;
writeln;
writeln('Hasil Tanspos matriks A (At) = ');
for x:=1 to ordo_y do
begin
for y:=1 to ordo_x do
begin
mat_C[x,y]:=mat_A[y,x];
write(mat_C[x,y]:5);
end;
writeln;
readln;
end;
end;


BEGIN
clrscr;
awal:
writeln;
menu;
writeln;
write('silahkan masukkan pilihan anda : ');readln(pil);
writeln('---------------------------------------------------');
case pil of
'1': begin penjumlahan;
end;
'2': begin pengurangan;
end;
'3': begin perkalian;
end;
'4': begin transpos;
end;

else writeln('TIDAK ADA DALAM DAFTAR MENU');

end;
writeln('----------------------------------------------------');
writeln;
writeln('apakah anda ingin menghitung lagi?(y/n)');
write('Jawab : ');readln(jawab);

if upcase(jawab)='Y' then
goto awal;
readln;

END.




Leave a Reply

Silahkan tulis komentar Anda dibawah ini

Subscribe to Posts | Subscribe to Comments

Cari Blog Ini

- Copyright © HeDes - Date A Live - Powered by Blogger - Designed by Johanes Djogan -