fork download
  1.  
  2. float F(float x,float a0,float a1,float a2,float a3)
  3. {
  4. float y;
  5. y=a0+a1*x*x+a2*x*x*x+a3*log10(1/x);
  6. return y;
  7. }
  8. main()
  9. {
  10. float b,a0, a1, a2, a3, xn,x1,x2;
  11. printf("vvedite koefficienty uravneniya: \n");
  12. scanf("%f%f%f%f", &a0,&a1,&a2,&a3);
  13. printf("1 nachal'noe priblizhenie: \n");
  14. scanf("%f", &x1);
  15. printf("2 nachal'noe priblizhenie: \n");
  16. scanf("%f", &x2);
  17.  
  18. while (F(x1,a0,a1,a2,a3)>0.001 || abs(x2-x1)>0.001)
  19. {
  20. xn=(x2-((x2-x1)/(F(x2,a0, a1, a2, a3)-F(x1,a0, a1, a2, a3)))*F(x2,a0, a1, a2, a3);
  21. x1=x2;
  22. x2=xn;
  23. printf ("znach korn %f\n", xn);
  24. printf ("znach f(x) %f\n", F(x2,a0,a1,a2,a3));
  25. }
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
 1 1 1 1
-200 200
compilation info
prog.cpp: In function ‘float F(float, float, float, float, float)’:
prog.cpp:5:38: error: ‘log10’ was not declared in this scope
     y=a0+a1*x*x+a2*x*x*x+a3*log10(1/x);
                                      ^
prog.cpp: In function ‘int main()’:
prog.cpp:11:49: error: ‘printf’ was not declared in this scope
     printf("vvedite koefficienty uravneniya: \n");
                                                 ^
prog.cpp:12:39: error: ‘scanf’ was not declared in this scope
      scanf("%f%f%f%f", &a0,&a1,&a2,&a3);
                                       ^
prog.cpp:18:46: error: ‘abs’ was not declared in this scope
   while (F(x1,a0,a1,a2,a3)>0.001 || abs(x2-x1)>0.001)
                                              ^
prog.cpp:20:86: error: expected ‘)’ before ‘;’ token
     xn=(x2-((x2-x1)/(F(x2,a0, a1, a2, a3)-F(x1,a0, a1, a2, a3)))*F(x2,a0, a1, a2, a3);
                                                                                      ^
stdout
Standard output is empty