//迭代法求a的两个根
float a;
printf("请输入一个数字:");
scanf("%f",&a);
float x1,x2;
x1=a/2;
x2=(x1+x1/2)/2;
while (fabs(x2-x1)>=1e-5) {
x1=x2;
x2=(x1+x1/2)/2;
}
printf("x1=%f\nx2=%f",x1,x2);
//迭代法求a的两个根
float a;
printf("请输入一个数字:");
scanf("%f",&a);
float x1,x2;
x1=a/2;
x2=(x1+x1/2)/2;
while (fabs(x2-x1)>=1e-5) {
x1=x2;
x2=(x1+x1/2)/2;
}
printf("x1=%f\nx2=%f",x1,x2);