Program SPL_Lengkap;
USES CRT;
VAR
I,J,K,N : INTEGER;
P,JUMLAH : REAL;
A : ARRAY [0..99,0..99] OF REAL;
X : ARRAY [0..99] OF REAL;
BEGIN
CLRSCR;
WRITE ('MASUKKAN UKURAN MATRIKS :'); READLN(N);
FOR I := 1 TO N DO
BEGIN
FOR J := 1 TO N+1 DO
BEGIN
WRITE('A(',I,',',J,') :');READLN(A[I,J]);
END;
END;
{TAHAP I}
FOR K := 1 TO N-1 DO
BEGIN
FOR I := K+1 TO N DO
BEGIN
P:= A[I,K]/A[K,K];
FOR J:= K+1 TO N+1 DO
BEGIN
A[I,J]:= A[I,J]-P*A[K,J];
END;
A[I,K]:=0;
END;
END;
{TAHAP II}
X[N]:=A[N,N+1]/A[N,N];
FOR I:= N-1 DOWNTO 1 DO
BEGIN
JUMLAH :=0;
FOR J:= I+1 TO N DO
BEGIN
JUMLAH := JUMLAH + A[I,J]*X[J];
END;
X[I]:= (A[I,N+1]-JUMLAH)/A[I,I];
END;
WRITELN('NILAI X YANG DICARI');
FOR I:= 1 TO N DO
BEGIN
WRITELN('X(',I,')= ',X[I]:0:2);
END;
READLN;
END.
by: Yul
Tidak ada komentar:
Posting Komentar