Задача: Код
Исходник: лаба3, язык: C [code #623, hits: 9947]
аноним: Володька [добавлен: 17.03.2011]
  1. #include "stdafx.h"
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <math.h>
  5. #include <iostream.h>
  6. #define pi 3.14
  7.  
  8. int a;
  9. double f(double x) {
  10. return a*x-(((pi)/2)-atan(x));
  11. }
  12. int main() {
  13. int n=0;
  14. double b,c,d,eps;
  15. eps=0.0000001;
  16. b=0;
  17. cout<<"Given the equation: ax=arcctgx \n";
  18. cout<<"a="; cin>>a;
  19. cout<<"endpoint="; cin>>c;
  20. do {
  21. d=(b+c)/2;
  22. if (f(d)*f(b)<=0) c=d;
  23. else b=d;
  24.  
  25. n+=1;
  26.  
  27. }
  28. while (fabs(b-c)>=eps);
  29. cout<<"answer: "<<d<<"\n";
  30. cout<<"number of iterations: "<<n<<"\n";
  31. getch();
  32. return 0;
  33. }

+добавить реализацию