codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
/* Print the value of pi */ #include <stdio.h> #include <stdlib.h> #if 0 #define const typedef int my_int; #endif typedef long long int my_int; const my_int RADIUS = 2 * 1000 * 1000; int main() { const my_int SQRADIUS= RADIUS * RADIUS; my_int numHits = 0; my_int x = 0; my_int y = RADIUS; for(x = 1; x <= RADIUS; ++x) { my_int ySq = SQRADIUS - x*x; while(y*y > ySq) --y; numHits += 2 * y; } printf("Value of pi is: %g\n", 2.0 * numHits / SQRADIUS); return 0; }
Private
[
?
]
Run code
Submit