Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4.  
  5. float max(float q, float w)
  6. {
  7. if (q > w) return q;
  8. else return w;
  9.  
  10. }
  11.  
  12. int fact(int f)
  13. {
  14. if (f==1) return 1;
  15. else return(f*fact(f-1));
  16. }
  17.  
  18. int doublefact(int f)
  19. {
  20. if (f<=1) return 1;
  21. else return(f*doublefact(f-2));
  22. }
  23.  
  24. float min(float q, float w)
  25. {
  26. if (q < w) return q;
  27. else return w;
  28. }
  29.  
  30.  
  31.  
  32.  
  33. float qq(int n, float x)
  34. {
  35. return( ((doublefact(2*(n-1)))*(powf(x,2*n+1))) / ((doublefact(2*n))*(2*n+1)) );
  36. }
  37.  
  38.  
  39. int main()
  40. {
  41. float x, ff = 0, ff_1 = 100,ff_2=0;
  42. float n = 0;
  43. printf("Vvedite_parametr_x: \n");
  44. scanf("%f", &x);
  45.  
  46. printf("%f %f %f\n", ff, ff_1, ff_2);
  47. //while ((max(ff,ff_1)-min(ff,ff_1)) >= pow(10,-5))
  48. while (abs((ff-asin(x)))>=pow(10,-5))
  49. {
  50. ff_2 = ff_1;
  51. ff_1 = ff;
  52. ff += qq(n, x);
  53. printf("%f %f %f\n", ff, ff_1, ff_2);
  54. n++;
  55. }
  56.  
  57. //for (int i=0;i<10;i++)
  58. printf("The answer is %f\n", ff_1);
  59. //printf("%d",fact(5));
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement