From adfef311025815f18da300936ff86998646191e8 Mon Sep 17 00:00:00 2001 From: kmazouzi Date: Mon, 18 Apr 2016 09:29:10 +0200 Subject: [PATCH] add n --- lab1/pi_mpi.c | 7 +++++-- lab1/pi_omp.c | 7 ++++--- lab1/pi_ser.c | 9 +++++---- lab1/pi_task.c | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lab1/pi_mpi.c b/lab1/pi_mpi.c index 2f2be47..0c14c7b 100644 --- a/lab1/pi_mpi.c +++ b/lab1/pi_mpi.c @@ -1,7 +1,10 @@ #include +#include #include + + #include -#define N 100000000 +#define N 1000000000 int main (int argc, char** argv) { @@ -50,7 +53,7 @@ int main (int argc, char** argv) if(rank==0) { - printf("Pi=%0.12g\n", total_sum); + printf("Pi=%0.20g\n", total_sum); } diff --git a/lab1/pi_omp.c b/lab1/pi_omp.c index b3684b5..d39a313 100644 --- a/lab1/pi_omp.c +++ b/lab1/pi_omp.c @@ -3,7 +3,8 @@ #include #include -#define N 100000000 +#define N 1000000000 + int main (int argc, char** argv) { long long int n; @@ -15,7 +16,7 @@ int main (int argc, char** argv) if(argc==2) { - n=atol(argv[1]); + n=atoll(argv[1]); } @@ -32,7 +33,7 @@ int main (int argc, char** argv) l_sum *= h; - printf("N=%lld,PI=%0.12g\n",n, l_sum); + printf("N=%lld,PI=%0.20g\n",n, l_sum); return 0; } diff --git a/lab1/pi_ser.c b/lab1/pi_ser.c index b3676cb..ef6c1d4 100644 --- a/lab1/pi_ser.c +++ b/lab1/pi_ser.c @@ -1,22 +1,23 @@ #include #include #include -#define N 100000000 +#define N 1000000000 + int main (int argc, char** argv) { long long int n; long long int i; - double l_sum, x, h; n=N; if(argc==2) { - n=atol(argv[1]); + n=atoll(argv[1]); } + h = 1.0/n; l_sum = 0.0; @@ -29,7 +30,7 @@ int main (int argc, char** argv) l_sum *= h; - printf("N=%lld, PI = %0.12g\n",n ,l_sum); + printf("N=%lld, PI = %0.20g\n",n ,l_sum); return 0; } diff --git a/lab1/pi_task.c b/lab1/pi_task.c index 6298901..614c03f 100644 --- a/lab1/pi_task.c +++ b/lab1/pi_task.c @@ -2,7 +2,7 @@ #include #include -#define N 100000000 +#define N 1000000000 int main (int argc, char** argv) { @@ -43,7 +43,7 @@ int main (int argc, char** argv) l_sum *= h; - printf("Pi=%0.12g\n", l_sum); + printf("Pi=%0.20g\n", l_sum); return 0; } -- 1.7.10.4