Tugas Prokom – Matriks

Program matriks
Kamus :
A : array [1..10,1..10] of integer
B : array [1..10,1..10] of integer
C : array [1..10,1..10] of integer
I, j, pil : integer
Procedure penjumlahan
Procedure pengurangan
Procedure perkalian

Algoritma :
Input (n)
i traversal [1..n]
j traversal [1..n]
input (A[i,j])
i traversal [1..n]
j traversal [1..n]
input (B[i,j])

output (‘1.penjumlahan 2.pengurangan 3. Perkalian’)
input (pil)
depend (pil) on
1 : penjumlahan
2 : pengurangan
3 : perkalian

i traversal [1..n]
j traversal [1..n]
output (C[i,j])

procedure penjumlahan
kamus :
algoritma :
i traversal [1..n]
j traversal [1..n]
C [i,j] <- A[i,j] + B[i,j]

Procedure pengurangan
Kamus :
Algoritma :
i traversal [1..n]
j traversal [1..n]
C [i,j] <- A[i,j] – B[i,j]

Procedure perkalian
Kamus :
Z, temp : integer
Algoritma :
temp <- 0
i traversal [1..n]
j traversal [1..n]
z traversal [1..n]
temp <- temp + A[i,z] * B[z,j]
C[i,j] <- temp

Tugas PROKOM ~ Mesin Abstrak

TUBES BIKIN RAJIN

Mencari 3 Huruf

Versi 1

Program cariTUB

Kamus

CPTTUB : integer

C1,C2 : CHAR

Algoritma

Start-couple

CPTTUB <- 0

While (CC ≠ ‘.’) do

If (C1 = ‘T’ and C2 =’U') then

ADV-Couple; ADV-Couple

If (C1 = ‘B’) then

CPTTUB <- CPTTUB + 1

ADV-Couple

Output (CPTTUB)

Versi 2

Program cariTUB

Kamus

CPTTUB : integer

Prec-is-T : Boolean

Algoritma :

Prec-Is-T ← false

CPTTUB ← 0

START

while CC ≠ ‘.’ do

Prec-Is-T ← CC = ‘T’

ADV

if CC = ‘U’ and Prec-Is-T then

ADV

If CC = ‘B’ then

CPTTUB = CPTTUB + 1

ADV

Output (CPTTUB)

Mencari 4 Huruf

Versi 1

Program cariUBES

Kamus

CPTUBES : integer

C1,C2 : CHAR

Algoritma

Start-couple

CPTUBES <- 0

While (CC ≠ ‘.’) do

If (C1 = ‘U’ and C2 =’B') then

ADV-Couple ; ADV-Couple

If (C1 = ‘E’ and C2 = ‘S’) then

CPTUBES <- CPTUBES +1

ADV-Couple

Output (CPTUBES)

Versi 2

Program cariUBES

Kamus

CPTUBES : integer

Prec-is-U , Prec-is-E : Boolean

Algoritma :

Prec-Is-U ← false

Prec-Is-E ← false

CPTUBES ← 0

START

while CC ≠ ‘.’ do

Prec-Is-U ← CC = ‘U’

ADV

if CC = ‘B’ and Prec-Is-U then

ADV

Prec-Is-E ← CC = ‘E’

ADV

If CC = ‘S’ and Prec-Is-E then

CPTUBES = CPTUBES + 1

ADV

Output (CPTUBES)

Mencari 5 Huruf

Versi 1

Program cariTUBES

Kamus

CPTTUBES : integer

C1,C2 : CHAR

Algoritma

Start-couple

CPTTUBES <- 0

While (CC ≠ ‘.’) do

If (CC = ‘T’) then

ADV-Couple

If (C1 = ‘U’ and C2 = ‘B’) then

ADV-Couple ; ADV-Couple

If (C1 = ‘E’ and C2 = ‘S’) then

CPTTUBES <- CPTTUBES +1

ADV-Couple

Output (CPTTUBES)

Versi 2

Program cariTUBES

Kamus

CPTTUBES : integer

Prec-is-T , Prec-is-B : Boolean

Algoritma :

Prec-Is-T ← false

Prec-Is-B ← false

CPTTUBES ← 0

START

while CC ≠ ‘.’ do

Prec-Is-T ← CC = ‘T’

ADV

if CC = ‘U’ and Prec-Is-T then

ADV

Prec-Is-B ← CC = ‘B’

ADV

If CC = ‘E’ and Prec-Is-B then

ADV

If CC = S then

CPTTUBES = CPTTUBES + 1

ADV

Output (CPTTUBES)