fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define PARTS 740000000
  4.  
  5. int main(void) {
  6. double old_y,new_y,old_x,new_x,d,S;
  7. int i;
  8.  
  9. d = 1.0 / PARTS;
  10. S = 0;
  11. old_y = 1;
  12. old_x = 0;
  13.  
  14. for (i = 1;i <= PARTS;i++) {
  15. new_x = i * d;
  16. new_y = sqrt(1 - new_x * new_x);
  17.  
  18. S += ((old_y + new_y) * d / 2);
  19.  
  20. old_y = new_y;
  21. old_x = new_x;
  22. }
  23.  
  24. printf ("分割数 = %d,π = %0.9f\n",PARTS,S * 4);
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 4.98s 5456KB
stdin
Standard input is empty
stdout
分割数 = 740000000,π = 3.141592654