📄 xt3-23.cpp
字号:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{float a,x0,x1;
cout<<"enter a positive number:";
cin>>a; // 输入a的值
x0=a/2;
x1=(x0+a/x0)/2;
do
{x0=x1;
x1=(x0+a/x0)/2;
}
while(fabs(x0-x1)>=1e-5);
cout<<"The square root of "<<a<<" is "<<x1<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -