Senin, 17 Januari 2011

PROGRAM MATRIKS SKALAR

Berikut ini adalah source codenya :
 

uses wincrt;
type data = array[1..10,1..10] of integer;
var
   m1, m2, m3 : data;
   hasilmatriks : array [1..5, 1..5] of integer;
   m : data;
   i, j, u, v, w, a, b, c, k, skalar : integer;

procedure InputMatriks;
begin
  clrscr;
  writeln('***** Input Ordo Matriks (A x B) *****');
  write('Nilai A : '); readln(a);
  write('Nilai B : '); readln(b);
  clrscr;
  writeln('*** Input Matriks ***');
  gotoxy(1,3);
  writeln('Matriks');

  for i := 1 to a do
    begin
    k := 1;
      for j := 1 to b do
      begin
      gotoxy(j + k, i + 3);
      readln(m3[i, j]);
      k := k + 5;
      end;
    end;
end;

procedure KaliSkalar;
begin
  write('Masukkan nilai skalar yang akan dikalikan : '); readln(skalar);
  for i := 1 to a do
    begin
    for j := 1 to b do
      begin
      hasilmatriks[i, j] := skalar * m3[i,j];
      end;
    end;
end;

procedure TampilMatriks;
begin
  gotoxy(1, 2);
  writeln('Matriks');
  for i := 1 to a do
    begin
    k := 1;
    for j := 1 to b do
      begin
      gotoxy(j + k, i + 2);
      writeln(m3[i, j]);
      k := k + 3;
      end;
    end;
    writeln('Dikalikan dengan nilai skalar ', skalar);
end;

procedure TampilHasilMatriks;
begin
  gotoxy(1, a + 6);
  writeln('Hasil');
  for i := 1 to a do
    begin
    k := 1;
    for j := 1 to b do
      begin
      gotoxy(j + k, i + a + 6);
      writeln(hasilmatriks[i, j]);
      k := k + 5;
      end;
    end;
end;

{* PROGRAM UTAMA *}
begin
     InputMatriks;
     clrscr;
     KaliSkalar;
     TampilMatriks;
     TampilHasilMatriks;
end
.

0 komentar:

Posting Komentar

Silahkan Kunjungi Juga :

MTGW Poll >>> klik disini
Jundullah D3 Teknik Mesin ITS >>> klik disini
Cah Glugu from Zero to Hero >>> klik disini
 
;