1
(17) (PR) . | |
. | |
. | |
. | |
. | |
. | |
: ? | |
. | |
. | |
. | |
. | |
(10) (max) (min) (pr_pol) . | |
(15) (SR) (pr_otr). | |
(30) (SR). | |
(17) (kol) , 5. | |
Z(15) (S) (PR) , 0 21. | |
(17) (kol) , . | |
Z(15) (S) (SR) , 0 15. | |
(17) (kol) , . | |
(10) . |
20
SR = S / N
S
N
Excel (. 1).
. 1.
:
Sub pol()
Const n = 10
Dim B(1 To n) As Integer
Dim S, SR, kol As Single
Excel
Sheets(" ").Activate
Excel
For I = 1 To n
B(I) = Cells(3, I + 1)
Next I
S = 0
kol = 0
|
|
For I = 1 To n
If B(I) > 0 Then
S = S + B(I)
kol = kol + 1
End If
Next I
If kol = 0 Then
MsgBox( Ҕ)
Else
SR = S / kol
Cells(5, 1) = SR
Cells(5, 2) = SR
End If
End Sub
2. , 10 . InputBox, CheckBox. . 2.
2
(5) : , , . | |
(5) : max- , l- , . | |
(10) : , , , 5 10, . | |
(5) : , , , , 3. | |
10 , , . | |
( ) 2011 . : , ( , . | |
(10) : , , . | |
(10) : , 5, 5 8 , . | |
(10), . : , 9, , . | |
(10) : , . |
10
1. (.2).
2. Label1, Textbox1 ( Multiline=True, ScrollBars=2-fmScrollbarsVertical), Frame1, CheckBox1, CheckBox2, CheckBox3 ( WordWrap=True), TextBox2, TextBox3, TextBox4, CommandButton1, CommandButton2, CommandButton3.
3. .
, n i .
Dim A(9) As Integer
Dim n, i As Integer
.
. 2. 2
:
Dim A(9) As Integer
Dim n, i As Integer
Private Sub CommandButton1_Click()
Dim k As String
n = 9
TextBox1.Text = ""
For i = 0 To n
k = InputBox(" " + CStr(i + 1) + " ")
|
|
A(i) = Val(k)
TextBox1.Text = TextBox1.Text + " " + CStr(A(i)) + vbCrLf
Next i
End Sub
Private Sub CommandButton2_Click()
Dim max, p, r, s As Integer
Dim sred As Single
If CheckBox1.Value = True Then
max = 0
For i = 1 To n
If A(i) > A(max) Then max = i
Next i
TextBox2.Text = CStr(A(max))
End If
If CheckBox2.Value = True Then
p = 0
For i = 0 To n
If A(i) Mod 2 <> 0 Then p = p + 1
Next i
TextBox3.Text = CStr(p)
End If
If CheckBox3.Value = True Then
s = 0
r = 0
For i = 0 To n
If A(i) < 0 Then
s = s + A(i)
r = r + 1
End If
Next i
If r = 0 Then
MsgBox (" ")
CommandButton1.SetFocus
Else
sred = s / r
TextBox4.Text = CStr(sred)
End If
End If
End Sub
Private Sub CommandButton3_Click()
End
End Sub