Commit | Line | Data |
---|---|---|
8de51304 H |
1 | #include <stdio.h>\r |
2 | #include <math.h>\r | |
3 | #include <time.h>\r | |
4 | #define PI 3.141592653589793\r | |
5 | \r | |
6 | int main(void) {\r | |
7 | double currPi=0, i=1;\r | |
8 | clock_t begin, end;\r | |
9 | \r | |
10 | begin = clock();\r | |
11 | do {\r | |
12 | currPi+=(4/i - 4/(i+2));\r | |
13 | i+=4;\r | |
14 | } while(fabs(PI-currPi) > 1e-7);\r | |
15 | end = clock();\r | |
16 | \r | |
17 | printf("Vypocteno Pi = %lf v case: %f ms.\n", currPi,\r | |
18 | (float)(end-begin)/CLOCKS_PER_SEC * 1000);\r | |
19 | \r | |
20 | //system("PAUSE");\r | |
21 | //return EXIT_SUCCESS;\r | |
22 | }\r |