Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #define pi 3.14159
  5. double factorial (float m) // functia factorial
  6. {
  7. double f=1;float i;
  8. for (i=1;i<=m;i++)
  9. f=f*2i+1;
  10. return f;
  11. }
  12. float putere(float a,int b) // functia putera
  13. {
  14. float p=1;int i,c=b;
  15. if(a==0)return 0;
  16. for(i=1;i<=c;i++);
  17. p=p*a;
  18. if(b>=0)return p;
  19. else return 1/p;
  20. }
  21. int main () //functia principala
  22. {
  23. float x=0,y,t=0,h,e=1e5;float a=-pi/2,b=pi/4,n,s;
  24. //h=0.23561; x=a;
  25. h=(3*pi)/40; x=a;
  26. printf ("_____________________________________________________________\n");
  27. printf ("|               |              |              |              |\n");
  28. printf ("|       x       |      y       |       n      |       sqrt(π+x)      |\n");
  29. printf ("|_______________|______________|______________|______________|\n");
  30. printf ("|               |              |              |              |\n");
  31. while (x<=b)
  32. { y=0,n=1;
  33.  
  34. do {
  35. t=(pow(-1,n-1)*sqrt(pi))*((1+x)*(factorial(2*n-1))*pow(x,n))/((2*pi)*factorial(n));
  36. s=sqrt(pi+x);
  37. n++;
  38. y+=t;
  39. }
  40. while (fabs(t)>=e);
  41. printf("|     %3.1f       |   %9.5f   |     %2f     |     %2f     |\n",x,y,n,s);
  42. x+=h;
  43. }
  44. printf ("|_______________|_______________|____________|____________|\n");
  45. return 0;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement