1

Topic: To find an arithmetic average

Hello. And form usage requires to find an arithmetic average not elements of the set equal to zero
Vector X1, X2..., Xn and to count a number of elements with the nonnegative
Values (including and the elements equal to zero).

2

Re: To find an arithmetic average

It is required? Well do...

3

Re: To find an arithmetic average

That, tried to do?

4

Re: To find an arithmetic average

Roman Mejtes wrote:

that, tried to do?

While I can offer it only
List <int> arr = new List <int> {35, 55,-45, 0, 7, 57};
int m = 0;
float avr = 0;
int c = 0;
for (int i = 0; i <arr. Count; i ++)
{
var tmp = arr [i];
if (tmp == 0) {continue;}
if (tmp> 0) {m ++;}
c ++;
avr + = tmp;
}
avr = avr / (float) c;

5

Re: To find an arithmetic average

fantanol wrote:

I can offer only it

And at what here VB?

6

Re: To find an arithmetic average

The_Prist wrote:

it is passed...
And at what here VB?

Well though a sketch even from other environment. To represent algorithm

7

Re: To find an arithmetic average

fantanol;
And, well here to you this algorithm on VB:

Sub ttt ()
Dim arr (), m As Long, i As Long, tmp As Double, avr As Double
arr = Array (35, 55,-45, 0, 7, 57)
For i = 0 To UBound (arr)
tmp = arr (i)
If tmp> 0 Then
m = m + 1
End If
avr = avr + tmp
Next
avr = avr / m
End Sub

8

Re: To find an arithmetic average

The_Prist wrote:

fantanol;
And, well here to you this algorithm on VB:

Sub ttt ()
Dim arr (), m As Long, i As Long, tmp As Double, avr As Double
arr = Array (35, 55,-45, 0, 7, 57)
For i = 0 To UBound (arr)
tmp = arr (i)
If tmp> 0 Then
m = m + 1
End If
avr = avr + tmp
Next
avr = avr / m
End Sub

Only I without concept as with it to be further where to substitute and .

9

Re: To find an arithmetic average

fantanol;
Show to the teacher or plainly explain, what is necessary?

10

Re: To find an arithmetic average

by-pass wrote:

Show to the teacher or plainly explain, what is necessary?

show to the teacher, tell, what muzhiks with sql.ru are interested, what further?

11

Re: To find an arithmetic average

by-pass wrote:

fantanol;
Show to the teacher or plainly explain, what is necessary?

Here the task to find an arithmetic average not elements of the set equal to zero
Vector X1, X2..., Xn and to count a number of elements with the nonnegative
Values (including and the elements equal to zero).
It is all it is necessary to make on the form

Shocker. Pro wrote:

Show to the teacher, tell, what muzhiks with sql.ru are interested, what further?

Not in my case)

12

Re: To find an arithmetic average

fantanol wrote:

it is passed...
Not in my case)

you also are the teacher?

13

Re: To find an arithmetic average

Antonariy wrote:

it is passed...
You also are the teacher?

With such tasks I not be helped by the teacher