ALGORITM: Ikkita massivni birlashtirish. M va N o ‘lchamlarga ega tegishli ravishda ikkita A va V massiv
elementlari tartiblangan holda berilgan. Ush bu algoritm S massiviga
A va V massivini tartiblangan holda birlashtirib saqlangan, o ‘lchami
M + N. I, J, К massiv indekslari.
1 . K - l J < - 1 K < - 1
2. Repeat While ((I < M) AND (J < N))
Begin
IF
(Aril CfKl<- Aflll < - 1 + 1
End
ELSE
Begin
CfKl<- B fll J <- J + 1
End
K < - K + 1
End
3. IF (I > M ) THEN
Begin
Repeat W hile (J < N)
Begin
CfKl<- B1J1J <- J + 1 К <- К + 1
281
End
End
ELSE
Begin
Repeat W hile (I < M)
Begin
CfKl<- A flll < - 1 + 1 К <- К + 1
End
End
4.
END.
A L G O R IT M : M a trits a la rn i b ir-b irig a k o ‘p ay tirish .
Berilgan ikkita matritsa A o ‘lchami M xN va V o ‘lchami PxQ.
M azkur algoritm S m atritsaga A va V matritsalarni ko'paytirm asini
saqlaydi
(MxQ
1 STEP 2
2 STEP 3
o'lcham li). I, J, К massiv indekslari.
1. IF n * p THEN Begin
W rite “M atrix multiplication not possible” goto step 3
End
2. Repeat for I = 1, 2,, m
Begin
Repeat for J = 1,
2„ q
Begin
CfI,Jl <- 0
Repeat for К = 1, 2 ,, n
CfI,Jl<- CfI,Jl+ (AfI,KlX B fK Jl)
End
End
2.
END.
STEP N + IS N
STEP N + 2 UNTIL (Condition)
STEP N + 1 SN
STEP N + 2 UNTIL (Condition)
282
Blok-chizmalarga misollar.
Quyidagi
blok-chizmada
Selsiy bo'yicha temperaturani
Farengeyt bo'yicha gradusga °F q g- x °C Q 32.0 formulasi
yordamida o'tkazish.
Boshlash
Kiritish С