69,382
社区成员
发帖
与我相关
我的任务
分享
# include <stdio.h>
# include <math.h>
# define eps 1e-6
int main(void)
{
float x0, x1;
x0 = 2.0;
x1 = (1 + x0*x0*cos(x0)) / (sin(x0) + x0*cos(x0));
do
{
x0 = x1;
x1 = (1 + x0*x0*cos(x0)) / (sin(x0) + x0*cos(x0));
}while(fabs(x0 - x1) > eps);
printf("%f", x1);
return 0;
}
# include <stdio.h>
# include <math.h>
# define eps 1e-6
int main(void)
{
float x0, x1;
x0 = 2.0;
x1= x0 - ((pow(x0, 41) + pow(x0, 3) + 1) / (pow(x0, 40) + 3*pow(x0, 2)));
do
{
x0 = x1;
x1= x0 - ((pow(x0, 41) + pow(x0, 3) + 1) / (pow(x0, 40) + 3*pow(x0, 2)));
}while (fabs(x1 - (-1)) > eps);
printf("%f\n", x1);
return 0;
}
//用C语言编程,求出2^x=x^10这个方程的解。
#include <math.h>
#include <stdio.h>
double x,e;
void main () {
x=-1.0;
e=0.001;
while (1) {
while (1) {
if (pow(2.0,x)<pow(x,10.0)) {
x+=e;
} else {
break;
}
}
e/=10.0;
if (e<1e-15) break;
while (1) {
if (pow(2.0,x)>pow(x,10.0)) {
x-=e;
} else {
break;
}
}
e/=10.0;
if (e<1e-15) break;
}
printf("%+.14g\n",x);
x=1.0;
e=0.001;
while (1) {
while (1) {
if (pow(2.0,x)>pow(x,10.0)) {
x+=e;
} else {
break;
}
}
e/=10.0;
if (e<1e-15) break;
while (1) {
if (pow(2.0,x)<pow(x,10.0)) {
x-=e;
} else {
break;
}
}
e/=10.0;
if (e<1e-15) break;
}
printf("%+.14g\n",x);
}