原创 牛頓法求平方根

對於給定的輸入N,求平方根的公式是 x(k+1) =   (xk + N/xk)/2; 需要設置一個 N的平方根的初始估計值。取N的值就可以。 #include <stdio.h> double newton(double d) {

原创 Finding Square Roots Using Newton’s Method

Let A > 0 be a positive real number. We want to show that there is a real number x with x^2 = A.  We already know that

原创 POJ 1064: Cable master

Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 83304   Accepted: 16926 Description Inhabitan

原创 format specifier floating point values in printf and scanf..

  "%f" is the (or at least one) correct format for a double in printf. There is no format for a float, because if you a

原创 LeetCode 4. Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The

原创 二分查找算法細節詳解

思路 我相信對很多讀者朋友來說,編寫二分查找的算法代碼屬於玄學編程,雖然看起來很簡單,就是會出錯,要麼會漏個等號,要麼少加個 1。 不要氣餒,因爲二分查找其實並不簡單。看看 Knuth 大佬(發明 KMP 算法的那位)怎麼說的: Alth