1. (x, y) S (. 1).
(x, y) S.
, S XOY :
|
FLAG Boolean.
FLAG, true, , (x, y) S, :
FLAG = (X>=-A) AND (X<=A) AND ((Y<=(A*AX*X)^(1/2) AND (Y>=0))
OR ((Y<0) AND (Y>=B)))
, ,
FLAG = X>=-A AND X<=A AND (Y<=(A*AX*X)^(1/2) AND Y>=0 OR
Y<0 AND Y>=B)
pr1.
Sub pr1()
Dim A As Double, B As Double
Dim X As Double, Y As Double
Dim Flag As Boolean
A = InputBox( A )
B = InputBox( B )
X = InputBox( X )
Y = InputBox( Y )
Flag = X>=-A AND X<=A AND _
(Y>=0 AND Y<=(A*AX*X)^(1/2) OR Y<0 AND Y>=B)
If Flag Then
MsgBox( )
Else
MsgBox( )
EndIf
EndSub
2. X Y :
. IF . (. - . 2). , . X true, false. , , , true.
pr2_1.
If . -, . 2. pr2_2.
. 2. - 2 ( pr2_1)
. 2. - 2 ( pr2_2)
Sub pr2_1() Dim X As Double, Y As Double X=InputBox( X ) If X<=0 Then Y=1/4*(Abs(X)+1)^(1/4) End If If X>0 And X<1 Then Y=1/3*X^(1/3) End If If X>=1 Then Y=1/2*X^(1/2) End If MsgBox(Y= & Y) End Sub | Sub pr2_2() Dim X As Double, Y As Double X = InputBox(X ) If X<=0 Then Y=1/4*(Abs(X)+1)^(1/4) ElseIf X>0 And X<1 Then Y=1/3*X^(1/3) Else Y=1/2*X^(1/2) End If MsgBox(Y= & Y) End Sub |
3. , X Y = F(X), F(X) . 3.
, , , F(X). . , , , , 2.
|
|
(. . 3) , - , . Y = X1 X ≤ 0. 0 ≤ X ≤ 1 Y = X 1. Y = 0 X ≥ 1. , :
- . 4.
pr3.
Sub pr3()
Dim X As Double, Y As Double
X = InputBox( X )
If X >= 1 Then
Y = 0
ElseIf X <= 0 Then
Y = -X - 1
Else
Y = X 1
End If
MsgBox(Y= & Y)
End Sub
. 4. - 3
4. , X Y = F(X), F(X) . 5.
, , X<-2 Y . , .
:
- . 6, pr4_1.
. 6. - 4 ( pr4_1)
Sub pr4_1()
Dim X As Double, Y As Double
X = InputBox( X )
If X >= 1 Then
Y = 0
MsgBox(Y= & Y)
ElseIf X > 0 And X < 1 Then
Y = X 1
MsgBox(Y= & Y)
ElseIf X >= -2 And X <= 0 Then
Y = -X 1
MsgBox(Y= & Y)
Else
MsgBox( )
End If
End Sub
, mist, false, < -2 true. mist, Y, , . - . 7. pr4_2.
. 7. - 4 ( pr4_2)
Sub pr4_2()
Dim XAs Double, Y As Double, mist As Boolean
mist = false
X = InputBox(X )
If X >= 1 Then
Y = 0
ElseIf X > 0 And X < 1 Then
Y = X 1
ElseIf X >= -2 And X <= 0 Then
Y = X 1
Else
mist = true
End If
If mist Then
MsgBox( )
Else
MsgBox(Y= &Y)
End If
End Sub
5. K X Y = F(X) :
- If . 8, pr5_If.
Sub pr5_If()
Dim X As Double, Y As Double, K As Integer, mist As Boolean
X = InputBox(X=)
K = InputBox(K=)
mist=false
If K=2 Or K=3 Then
|
|
Y = X^K + X + 1
ElseIf K>=4 And K<=10 Then
If X<>-1 Then
Y=1/Abs(X+1)
Else
mist=true
End If
Else
Y=Abs(X+K)^(1/2)+ Abs(X-K)^(1/2)
End If
If Not mist Then
MsgBox(Y= &Y)
Else
MsgBox( )
End If
End Sub
. 8. - 5 ( pr5_If)
Select Case. - Select Case - If. -, . 9, pr5_Case.
. 9. - 5 ( pr5_Case)
Sub pr5_Case()
Dim X As Double, Y As Double, K As Integer, mist As Boolean
X = InputBox(X=)
K = InputBox(K=)
mist = false
Select Case K
Case 2, 3
Y = X^K + X + 1
Case 4 To 10
If X<>-1 Then
Y = 1 / Abs(X+1)
Else
mist = true
End If
Case Else
Y = Abs(X+K)^(1/2) + Abs(X-K)^(1/2)
End Select
If Not mist Then
MsgBox(Y= & Y)
Else
MsgBox( )
End If
End Sub
6. X × Y L, W, H. , , . X, Y, L, W, H . , .
- . 12, pr6.
|
Sub pr6()
Dim X As Double, Y As Double
Dim L As Double, W As Double, H As Double
Dim d As Double
Dim Prompt As String
Dim cargo As Boolean
X = InputBox( X)
Y = InputBox( Y)
L = InputBox( L)
W = InputBox( W)
H = InputBox( H)
d = InputBox( d
L = L + d
W = W + d
H = H + d
L × W?
If X >= L And Y >= W Then
Prompt = Prompt & vbNewLine & _
L X, W Y
cargo = true
End If
If X >= W And Y >= L Then
Prompt = Prompt & vbNewLine & _
W X, L Y
cargo = true
End If
L × H?
If X >= L And Y >= H Then
Prompt = Prompt & vbNewLine & _
L X, H Y
cargo = true
End If
If X >= H And Y >= L Then
Prompt = Prompt & vbNewLine & _
H X, L Y
cargo = true
End If
H × W?
If X >= H And Y >= W Then
Prompt = Prompt & vbNewLine & _
H X, W Y
cargo = true
End If
If X >= W And Y >= H Then
Prompt = Prompt & vbNewLine & _
W X, H Y
cargo = true
End If
If cargo Then
MsgBox(Prompt)
Else
MsgBox( !)
End If
End Sub