The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: Moof on December 20, 2004, 05:28:07 PM

Title: average algorithm
Post by: Moof on December 20, 2004, 05:28:07 PM
Anyone has it, real mode, 16 bit registers
Title: Re: average algorithm
Post by: Jibz on December 20, 2004, 10:19:03 PM
Hmm .. what do you mean by average algorithm? Sum some numbers together and divide them by how many there were?

Sounds a bit like a homework assignment :wink.
Title: Re: average algorithm
Post by: roticv on December 22, 2004, 12:24:10 PM
I am really amused since you called finding an average an algorithm.  :toothy
Title: Re: average algorithm
Post by: Tedd on December 22, 2004, 05:03:06 PM
Average: (element1 + element2 + ele.....) DIV (number of elements)

This is about as obvious as it gets.

At least have a go - you might even learn something ;)
Title: Re: average algorithm
Post by: hador on December 24, 2004, 01:29:43 AM
Hi...

if you want more complicate algorithm take a look this:

avg_b[1] = a1/1

avg_b[2] = (a1+a2)/2 = ((1*a1/1)+a2)/2 = (1*avg_b[1]+a2)/2

avg_b[3] = (a1+a2+a3)/3 = ((2*((a1+a2)/2))+a3)/3 =(2*avg_b[2]+a3)/3

...
...

avg_b[n] = ((n-1)*avg_b[n-1]+an)/n


--HadorĀ  :8)