c# How to loop and count back in another loop?
Hi,
var Quodown = new List<int>() {9,7,6,9,7,6,4,3,0};
double sumi = 0;
double avg = 0;
for (int i = 8; i < Quodown.Count; i–)
{
sumi += Quodown[i];
Print(“sumi: “+ sumi);
//Print(i);
for (int y = i; y < 8; y++)
{
for (int z = Quodown.Count; z > 0; z–)
{
avg = sumi / z;
//Print(“avg: “+ avg);
Print(z);
}
}
}
I want to create a movering average of numbers calculated backward.
For exemple, in the first part of the code i calculate the sum of numbers backward 0+3 = 0, 0+3+4= 7 etc.
I am trying to get the moving average of the sum of those numbers like average of 0 = 0 than 3+0 = 3/2 = 1.5
4 +3 +0 = 7/3 = 2.333
etc
but using this loop it is dividing by its last position 8, 7 , 6 when it should be 3,2,1
Any help?
Thank you
Hi, var Quodown = new List<int>() {9,7,6,9,7,6,4,3,0};
double sumi = 0;
double avg = 0;
for (int i = 8; i < Quodown.Count; i–)
{
sumi += Quodown[i];
Print(“sumi: “+ sumi);
//Print(i);
for (int y = i; y < 8; y++)
{
for (int z = Quodown.Count; z > 0; z–)
{
avg = sumi / z;
//Print(“avg: “+ avg);
Print(z);
}
}
}
I want to create a movering average of numbers calculated backward.For exemple, in the first part of the code i calculate the sum of numbers backward 0+3 = 0, 0+3+4= 7 etc.I am trying to get the moving average of the sum of those numbers like average of 0 = 0 than 3+0 = 3/2 = 1.5 4 +3 +0 = 7/3 = 2.333etcbut using this loop it is dividing by its last position 8, 7 , 6 when it should be 3,2,1 Any help?Thank you Read More