11.21-rasm
Ob’yekt
Xossa
O‘rnatilgan qiymatlari
Form1
Caption
Maksimal va minimal qiymatlarini aniqlash
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
PDF created with pdfFactory trial version
www.pdffactory.com
11.22-rasm
Blok-sxemasi
PDF created with pdfFactory trial version
www.pdffactory.com
PDF created with pdfFactory trial version
www.pdffactory.com
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
PDF created with pdfFactory trial version
www.pdffactory.com
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
PDF created with pdfFactory trial version
www.pdffactory.com
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
1.
R, A, B, C larni kiritish.
2.
A qiymati A,B,C qiymatlari ichidagi minimali ekanligini tekshirish.
3.
Agar minimal bo‘lsa, B ning C dan kichikligini tekshirish.
4.
Agar kichik bo‘lsa, A,B,C ketme-ketligini aniqlash.
5.
Agar yo‘q bo‘lsa, A,C,B ketme-ketligini aniqlash.
6.
Agar yo‘q bo‘lsa, B ning A,B,C qiymatlari ichida minimalligini tekshirish
7.
Agar minimal bo‘lsa, A ning C dan kichikligini tekshirish.
8.
Agar kichik bo‘lsa, B, A, C ketme-ketligini aniqlash.
9.
Agar yo‘q bo‘lsa, B,C,A ketme-ketligini aniqlash.
10.
Agar yo‘q bo‘lsa, A ning B dan kichikligini tekshirish.
11.
Agar kichik bo‘lsa, C, A, B ketme-ketligini aniqlash.
12.
Agar yo‘q bo‘lsa, C,B,A ketme-ketligini aniqlash.
13.
Parallelopipedning kichik diagonali illyuminatorning diametridan kichikligini tekshirish.
14.
Agar kichik bo‘lsa, “Seyfni chiqarish mumkin” degan xabarni ko‘rsatish.
15.
Agar yo‘q bo‘lsa, “Seyf illyuminatordan chiqmaydi” degan xabarni ko‘rsatish.
PDF created with pdfFactory trial version
www.pdffactory.com
11.25-rasm
Do'stlaringiz bilan baham: |