Label1
|
Caption
|
A ni kiriting
|
Label2
|
Caption
|
B ni kiriting
|
Label3
|
Caption
|
C ni kiriting
|
Label4
|
Caption
|
D ni kiriting
|
Label5
|
Caption
|
MAKSIMUM
|
Label6
|
Caption
|
MINIMUM
|
Command1
|
Caption
|
Hisoblash
|
Command2
|
Caption
|
Tugatish
|
Text1, Text2
Text3, Text4
Text5, Text6
|
Text
|
Text xossasi maydonini tozalash
|
11.22-rasm
Blok-sxemasi
Dastur kodi
Option Explicit
Private Sub Command1_Click()
Dim A, B, C, D As Single
Dim R1, R2 As Single
Dim MAX, MIN As Single
A = Val(Text1.Text)
B = Val(Text2.Text)
C = Val(Text3.Text)
D = Val(Text4.Text)
If A > B Then
R1 = A
Else
R1 = B
End If
If C > D Then
R2 = C
Else
R2 = D
End If
If R1 > R2 Then
MAX = R1
Else
MAX = R2
End If
If A < B Then
R1 = A
Else
R1 = B
End If
If C < D Then
R2 = C
Else
R2 = D
End If
If R1 < R2 Then
MIN = R1
Else
MIN = R2
End If
Text5.Text = Str(MAX)
Text6.Text = Str(MIN)
End Sub
Private Sub Command2_Click()
End
End Sub
11.23-rasm
11.24-rasm
11-misol: Tarmoqlanuvchi dastur
Cho‘kayatgan kemadan seyfni chiqarib olish masalasi. Agar illyuminator R radiusli doira shakliga, seyf AxBxC o‘lchamdagi to‘g‘riburchakli parallelopiped shakliga ega bo‘lsa, seyfni chiqarib olish mumkinmi yoki yo‘g‘mi, shuni tekshirishni dasturlash.
Seyfni chiqarib olish mumkin, agar uning eng kichik yoqining diagonali illyuminator diametridan kichik bo‘lsa. Shu bois parallelopipedning yoqlari mos ravishda AxB, AxC va BxC bo‘lsa, ularning ichidan diagonali illyuminator diametridan kichik bo‘lgan minimal juftligini aniqlash yetarli. Buning uchun parallelopipedning yoqlari o‘sish tartibida joylashtiriladi.
Algoritm
R, A, B, C larni kiritish.
A qiymati A,B,C qiymatlari ichidagi minimali ekanligini tekshirish.
Agar minimal bo‘lsa, B ning C dan kichikligini tekshirish.
Agar kichik bo‘lsa, A,B,C ketme-ketligini aniqlash.
Agar yo‘q bo‘lsa, A,C,B ketme-ketligini aniqlash.
Agar yo‘q bo‘lsa, B ning A,B,C qiymatlari ichida minimalligini tekshirish
Agar minimal bo‘lsa, A ning C dan kichikligini tekshirish.
Agar kichik bo‘lsa, B, A, C ketme-ketligini aniqlash.
Agar yo‘q bo‘lsa, B,C,A ketme-ketligini aniqlash.
Agar yo‘q bo‘lsa, A ning B dan kichikligini tekshirish.
Agar kichik bo‘lsa, C, A, B ketme-ketligini aniqlash.
Agar yo‘q bo‘lsa, C,B,A ketme-ketligini aniqlash.
Parallelopipedning kichik diagonali illyuminatorning diametridan kichikligini tekshirish.
Agar kichik bo‘lsa, “Seyfni chiqarish mumkin” degan xabarni ko‘rsatish.
Agar yo‘q bo‘lsa, “Seyf illyuminatordan chiqmaydi” degan xabarni ko‘rsatish.
11.25-rasm
Do'stlaringiz bilan baham: |