用迭代法求x=
,要求前后两次求出的x的差的绝对值小于10-5,求平方根的迭代公式为:
输入
一个数a。
输出
的值。
样例输入
2.0
样例输出
The square root of 2.00 is 1.41421
这道题我无语了...:
#include<bits/stdc++.h>
using namespace std;
int main()
{
double n;
cin >> n;
cout << "The square root of " << fixed << setprecision(2) << n << " is " << fixed << setprecision(5) << sqrt(n);
return 0;
}
创作不易,给个关注吧