📄 sqroot.cpp
字号:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << "Please enter a number: ";
double a;
cin >> a;
const double EPSILON = 1E-14;
double xnew = a;
double xold;
do
{
xold = xnew;
xnew = (xold + a / xold) / 2;
}
while (fabs(xnew - xold) > EPSILON);
cout << "The square root is " << xnew << "\n";
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -