#include <stdio.h>
#include <math.h>
#include <conio.h>
float a[100];
int n,chot,i;
float f(float x)
{
float p=0;
for(i=0;i<=n;i++) p=p*x+a[i];
return p;
}
float fx(float x)
{
float p=0;
p=0;
for(i=0;i<=n-1;i++)
p=p*x+n*a[i];
return p;
}
float giainghiem(float x)
{
int dem,so;
so=10000;
if(n==1) return a[1];
while (dem<so)
{
if(dem==so-1)
{
if (fabs(f(x))>0.1) { chot=1;return 0 ;}
return x;
}
x=x-f(x)/fx(x);
if(fabs(f(x))<0.00000000001) return x;
dem++;
}
return chot=1;
}
void chiadathuc(float x)
{
for(i=1;i<n;i++)
a[i]=a[i]+a[i-1]*x;
n=n-1;
}
main()
{
double x;
int ok=0;
printf("nhap da thuc bac n va cac he so :");scanf("%d",&n);
for(i=0;i<=n;i++)
{
fflush(stdin);
printf("nhap he so x^%d:",n-i);scanf("%f",&a[i]);
}
fflush(stdin);
while(n>0)
{
chot=0;
x=giainghiem(0);
if (chot==1)
{
if (ok==0) printf("\b phuong trinh vo nghiem");break;
}
if (ok==0) printf("phuong trinh co nghiem la :
");
printf("%10.6f
",x);
chiadathuc(x);
ok=1;
}
getch();
}
Trứng rung điều khiển từ xa Vibrator Spark Of Love Sản phẩm trứng rung bluetooth có điều khiển từ xa này được thiết kế với tông màu Rose Gold viền kim khí trải qua. kích tấc 7,4cm x 3,5cm giúp trứng...
TOP 3 trùy rung điều khiển từ xa...