[英]Using a BREAK statement to exit this while loop changes the value of the variable and gives incorrect answer. Need another way?
題: 編寫一個應用牛頓法的程序來計算和顯示用戶輸入的數字的平方根。 牛頓法的算法如下: 從用戶那里讀取 x 將 guess 初始化為 x/2 雖然 guess 不夠好 do 將 guess 更新為 guess 和 x/guess 的平均值 當該算法完成時,guess 包含平方根的近似值. 近似值的 ...