主题:求助求助求助
各位高手,请帮我看看哪里错了,谢谢!!!!!!!!
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
void main()
{
double x=1,a,t,m=0.1;
cout<<"please input a:"<<endl;
cin>>a;
while(m>1e-5){
t=x;
x=1/2*(x+a/x);
m=fabs(t-x);
cout<<"x="<<setiosflags(ios::fixed)<<setprecision(5)<<x<<endl;
}
cout<<"x="<<setiosflags(ios::fixed)<<setprecision(5)<<x<<endl;
}
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
void main()
{
double x=1,a,t,m=0.1;
cout<<"please input a:"<<endl;
cin>>a;
while(m>1e-5){
t=x;
x=1/2*(x+a/x);
m=fabs(t-x);
cout<<"x="<<setiosflags(ios::fixed)<<setprecision(5)<<x<<endl;
}
cout<<"x="<<setiosflags(ios::fixed)<<setprecision(5)<<x<<endl;
}