※Project 1 of Chap. 2.
The Babylonian algorithm to compute the square root of a number n is as follows:
1.Make a guess at the answer(you can pick n/2 as your initial guess)
2.Compute r=n/guess
3.Set guess=(guess+r)/2
4.Go back to step 2 for as many iterations asnecessary.The more you repeat step 2
and 3,the closer guess will become to the square root of n.
※Project 3 of Chap. 2.
Write a program that reads in two integers typed on the keyboard and outputs their
sum,difference,and product it.
2008年3月23日 星期日
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言