Program Penjumlahan Matrik dimensi 2x2 :
IDENTIFICATION DIVISION.
PROGRAM-ID. MATRIK.
AUTHOR. NURFITRIANA.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 I PIC 99.
77 J PIC 99.
01 MASUKAN.
02 MATRIK OCCURS 2 TIMES.
03 MAT1 OCCURS 2 TIMES PIC 9.
03 MAT2 OCCURS 2 TIMES PIC 9.
03 MAT-HASIL OCCURS 2 TIMES PIC ZZZ.
SCREEN SECTION.
01 HAPUS-LAYAR.
02 BLANK SCREEN.
PROCEDURE DIVISION.
MULAI.
DISPLAY HAPUS-LAYAR.
MOVE 2 TO LIN.
DISPLAY(LIN, 1) 'MATRIK PERTAMA'.
ADD 1 TO LIN.
PERFORM MATRIK1 VARYING I
FROM 1 BY I UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2.
MOVE 1 TO LIN.
DISPLAY(LIN, 30) 'MATRIK KEDUA'.
ADD 1 TO LIN.
PERFORM MATRIK2 VARYING I
FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2.
MOVE 1 TO LIN.
DISPLAY (10, 10) 'PENJUMLAHAN MATRIK'.
DISPLAY SPACE.
MOVE 13 TO COL.
PERFORM HITUNG-NILAI VARYING I
FROM 1 BY 1 UNTIL I > 1
AFTER J FROM 1 BY 1 UNTIL J > 1.
MOVE 13 TO COL.
PERFORM HITUNG-NILAI VARYING I
FROM 1 BY 1 UNTIL I > 2
AFTER J FROM 1 BY 1 UNTIL J > 2.
STOP RUN.
MATRIK1.
DISPLAY(LIN, 1) 'NILAI[', I , ',' , J , ']:'.
ACCEPT ( , ) MAT1(I, J).
ADD 1 TO LIN.
MATRIK2.
DISPLAY(LIN, 30) 'NILAI[', I , ',' , J , ']:'.
ACCEPT ( , ) MAT2(I, J).
ADD 1 TO LIN.
HITUNG-NILAI.
COMPUTE MAT-HASIL(I, J) = MAT1(I, J) + MAT2(I, J).
DISPLAY ( , COL) MAT-HASIL(I, J).
ADD 7 TO COL.
OUTPUT :
MATRIK PERTAMA
NILAI[01,01]: 2
NILAI[01,02]: 1
NILAI[02,01]: 3
NILAI[02,02]: 4
MATRIK KEDUA
NILAI[01,01]: 2
NILAI[01,02]: 8
NILAI[02,01]: 1
NILAI[02,02]: 6
PENJUMLAHAN MATRIK
4 9
4 10
Note : seharusnya hasil output matrik pertama dan kedua pd saat input nilai, layoutnya menyamping, tp saya tulis di blog, kebawah :D
Langganan:
Posting Komentar (Atom)
2 komentar:
ciehhhh,,,
pak wayan sll menjadi inspirasimu master,,
aku suka ini,,
skrg blogny jadi brubah haluan jadi coboL isinya,,heheh
miss u master..
hehehhe
iya intan, aku teringat akan pesan
Prof. Wayan, ya sapa tau ada perusahaan liat blog aku, eh aku diminta jd programmernya..
hehehe
aminnnn
Posting Komentar