标签:style blog http color os io art ar
#include<stdio.h> main() { float x=2.5,y,x1=2.5,a,b,c,d,max,min; scanf("%f%f%f%f",&a,&b,&c,&d); do { y=x-(a*x*x*x+b*x*x+c*x+d)/(3*a*x*x+2*b*x+c); x=y; }while((a*x*x*x+b*x*x+c*x+d)!=0); printf("%.3f\n",y); }
#include<stdio.h>
main()
{
float x=2.5,y,x1=2.5,a,b,c,d,max,min;
scanf("%f%f%f%f",&a,&b,&c,&d);
do
{
y=x-(a*x*x*x+b*x*x+c*x+d)/(3*a*x*x+2*b*x+c);
x=y;
}while((a*x*x*x+b*x*x+c*x+d)!=0);
printf("%.3f\n",y);
}
#include <stdio.h> #include <math.h> int main() { float a,b,c,d,x,fx,x1,fx1; scanf("%f%f%f%f",&a,&b,&c,&d); x1=2.5; do { x=x1; fx=a*x*x*x+b*x*x+c*x+d; fx1=3*a*x*x+b*2*x+c; x1=x-fx/fx1; } while (fabs(x1-x)>=1e-6); printf("%.3f\n",x); return 0; }
#include <stdio.h>
#include <math.h>
int main()
{
float a,b,c,d,x,fx,x1,fx1;
scanf("%f%f%f%f",&a,&b,&c,&d);
x1=2.5;
do
{ x=x1;
fx=a*x*x*x+b*x*x+c*x+d;
fx1=3*a*x*x+b*2*x+c;
x1=x-fx/fx1;
} while (fabs(x1-x)>=1e-6);
printf("%.3f\n",x);
return 0;
}
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main(int argc, char *argv[]) { float a,b,c,d,x,x1,f; cin>>a>>b>>c>>d; x1=2.5; do { x=x1; f=a*x1*x1*x1+b*x1*x1+c*x1+d; x1=x-f/(3*a*x1*x1+2*b*x1+c); } while (fabs(x-x1)>=1e-10); cout<<fixed<<setprecision(3)<<x<<endl; return 0; }
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
float a,b,c,d,x,x1,f;
cin>>a>>b>>c>>d;
x1=2.5;
do
{
x=x1;
f=a*x1*x1*x1+b*x1*x1+c*x1+d;
x1=x-f/(3*a*x1*x1+2*b*x1+c);
}
while (fabs(x-x1)>=1e-10);
cout<<fixed<<setprecision(3)<<x<<endl;
return 0;
}
标签:style blog http color os io art ar
原文地址:http://www.cnblogs.com/2014acm/p/3902542.html