b*******y 发帖数: 32 | 1 第一个google了一下,可以用Babynonian, O(n^2).
==================
#include
#include
using namespace std;
double Babylonian(double value) {
double root = value/2.0;
int steps = 100;
for (int i = 0; i < steps; i++){
root = 0.5*(root + value / root);
}
return root;
}
void compSqrt(double value) {
cout<<"Input: "<
<
}
int main()
{
compSqrt(5);
compSqrt( |
|