Membuat Program "Matrik" dengan Bahasa Pascal

uses wincrt;
type data = array[1..10,1..10] of integer;
var matrikI,matrikII : data;
    baris,kolom,pil : integer;
    Ul : char;
                                                                
procedure isimatrik;                                
var i,j : integer;
begin
     writeln('Penentuan ORDO MATRIK I');
     write('Masukkan banyak baris matrik I = ');readln(baris);
     write('Masukkan banyak kolom matrik I = ');readln(kolom);
     writeln;
      for i:=1 to baris do
         begin
         for j :=1 to kolom do
             begin
                  gotoxy(j*4,i+4);
                  read(matrikI[i,j]);
             end;
         end;

     writeln;
     writeln;
     writeln('Penentuan ORDO MATRIK II');
     write('Masukkan banyak baris matrik II = ');readln(baris);
     write('Masukkan banyak kolom matrik II = ');readln(kolom);
     writeln;
     writeln;
     for i:=1 to baris do
         begin
         for j:=1 to kolom do
             begin
                  gotoxy(j*4,i+13);
                  read(matrikII[i,j]);
             end;
         end;
             clrscr;
end;



procedure jumlahmatrik(m1,m2 : data; baris,kolom :integer);
var hasil : data;
    i,j : integer;
begin
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  hasil[i,j]:=m1[i,j]+m2[i,j];
             end;
     writeln;
     writeln('Hasil Penjumlahan MATRIK');
     for i:=1 to baris do
         for j :=1 to kolom do
             begin
                  gotoxy(j*4,i+4);
                  write(m1[i,j]);
             end;
     gotoxy(kolom+17,baris+3);
     write('+');
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  gotoxy((j*4)+27,i+4);
                  write(m2[i,j]);
             end;

     gotoxy(kolom+42,baris+3);
     write('=');
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  gotoxy((j*4)+50,i+4);
                  write(hasil[i,j]);
             end;
end;

procedure kurangmatrik(m1,m2 : data);
var hasil : data;
    i,j: integer;
begin
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  hasil[i,j]:=m1[i,j]-m2[i,j];
             end;
    
     writeln;
     writeln('Hasil Pengurangan MATRIK');
     for i:=1 to baris do
         for j :=1 to kolom do
             begin
                  gotoxy(j*4,i+4);
                  write(m1[i,j]);
             end;
     gotoxy(kolom+17,baris+3);
     write('-');
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  gotoxy((j*4)+27,i+4);
                  write(m2[i,j]);
             end;

     gotoxy(kolom+42,baris+3);
     write('=');
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  gotoxy((j*4)+50,i+4);
                  write(hasil[i,j]);
             end;
end;

procedure kalimatrik(m1,m2 :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]+m1[i,z]*m2[z,j];
             end;
     writeln;
     writeln('Hasil Perkalian MATRIK');
     for i:=1 to baris do
         for j :=1 to kolom do
             begin
                  gotoxy(j*4,i+4);
                  write(m1[i,j]);
             end;
     gotoxy(kolom+17,baris+3);
     write('*');
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  gotoxy((j*4)+27,i+4);
                  write(m2[i,j]);
             end;

     gotoxy(kolom+42,baris+3);
     write('=');
     for i:=1 to baris do
         for j:=1 to kolom do
             begin
                  gotoxy((j*4)+50,i+4);
                  write(hasil[i,j]);
             end;
end;

begin
repeat
clrscr;
     writeln(' =======================');
     writeln('         M E N U');
     writeln(' =======================');
     writeln(' (1) Penjumlahan Matrik');
     writeln(' (2) Pengurangan Matrik');
     writeln(' (3) Perkalian Matrik');
     writeln;
     write('Pilih = ');readln(pil);
     clrscr;
     case pil of
     1 : begin
              isimatrik;
              jumlahmatrik(matrikI,matrikII,baris,kolom);
         end;
     2 : begin
              isimatrik;
              kurangmatrik(matrikI,matrikII);
         end;
     3 : begin
              isimatrik;
              kalimatrik(matrikI,matrikII);
         end;
     end;
     writeln;
     writeln;
     writeln;
     write('Mau Ulang Lagi? [Y/T] : ');
     Ul :=readkey;
until(Ul='t');
halt(0);
end.

out put


misalkan anda memilih menu (1) maka out put yang akan tampil seperti ini
note: angka yang dimasukkan hanya sebagai contoh. angka dapat diubah sesuai keinginan anda.

 Final out put

 
 apabila anda ingin kembali ke menu utama ketik "Y"

- Selamat Mencoba -
Share this article :
 

+ komentar + 1 komentar

14 Januari 2014 pukul 09.11

maaf mba sebelumnya,,saya punya kisi-kisi algoritma tapi tidak bisa mengerjakannya jadi mohon bantuannya dengan sangat mba,,please

maaf juga berkomentar menggunakan link tapi ini soalnya,

https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-prn2/v/1598263_717790371565559_1875441599_n.jpg?oh=744d3233892d1bc42fcf600738922b1a&oe=52D6F29F&__gda__=1389790155_bddcb4037f60650f7754fae74dc663ee

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Serunya Belajar - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger