fork download
  1. #include<stdio.h>
  2. #include<math.h>
  3. #define f(x) sqrt(4-((x)*(x)))
  4. int main(void)
  5. {
  6. float n, i, sab, p, q, o, m, l, h, y,z;
  7. //scanf("%d", &n);
  8. n = 50;
  9. h=1/n;
  10. q=f(0)+f(2);
  11. for(i = 1; i <= n; i++){
  12. l=(3*i-2)* h;
  13. p+=f(l);
  14. }
  15. for(i = 1; i <= n; i++){
  16. m = (3*i-1)*h;
  17. o+=f(m);
  18. }
  19. for(i = 1; i <= n; i++){
  20. y = (3*i)*h;
  21. z+=f(m);
  22. }
  23. sab= 3*h/8*(q+3*p+3*o+2*z);
  24. printf("%f", sab);
  25. return(0);
  26. }
Success #stdin #stdout 0s 5392KB
stdin
Standard input is empty
stdout
-nan