Skip to content
Snippets Groups Projects
Commit 972c7bb7 authored by Xin Li's avatar Xin Li
Browse files

formatted C code in lab1

parent c356c06e
No related branches found
No related tags found
No related merge requests found
...@@ -16,8 +16,8 @@ serial version ...@@ -16,8 +16,8 @@ serial version
#define NSTEPS 500 /* number of time steps */ #define NSTEPS 500 /* number of time steps */
int main(int argc, char *argv[]) { int main(int argc, char *argv[])
{
int i, j, n, im, ip, jm, jp, ni, nj, nsum, isum; int i, j, n, im, ip, jm, jp, ni, nj, nsum, isum;
int **old, **new; int **old, **new;
float x; float x;
......
#include <stdio.h> #include <stdio.h>
#include <mpi.h> #include <mpi.h>
int main (int argc, char *argv[]) { int main (int argc, char *argv[])
{
int myrank, size; int myrank, size;
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
...@@ -11,4 +11,6 @@ int main (int argc, char *argv[]) { ...@@ -11,4 +11,6 @@ int main (int argc, char *argv[]) {
printf("Processor %d of %d: Hello World!\n", myrank, size); printf("Processor %d of %d: Hello World!\n", myrank, size);
MPI_Finalize(); MPI_Finalize();
return 0;
} }
#include <stdio.h> #include <stdio.h>
int main (int argc, char *argv[]) { int main (int argc, char *argv[])
{
const int N=300; const int N=300;
int i,target; int i,target;
int b[N]; int b[N];
...@@ -31,4 +32,3 @@ int main (int argc, char *argv[]) { ...@@ -31,4 +32,3 @@ int main (int argc, char *argv[]) {
return 0; return 0;
} }
...@@ -7,8 +7,8 @@ double dboard (int darts); ...@@ -7,8 +7,8 @@ double dboard (int darts);
#define ROUNDS 10 /* number of times "darts" is iterated */ #define ROUNDS 10 /* number of times "darts" is iterated */
#define MASTER 0 /* task ID of master task */ #define MASTER 0 /* task ID of master task */
int main (int argc, char *argv[]) { int main (int argc, char *argv[])
{
double homepi, /* value of pi calculated by current task */ double homepi, /* value of pi calculated by current task */
pi, /* average of pi after "darts" is thrown */ pi, /* average of pi after "darts" is thrown */
avepi, /* average pi value for all iterations */ avepi, /* average pi value for all iterations */
...@@ -16,7 +16,6 @@ double homepi, /* value of pi calculated by current task */ ...@@ -16,7 +16,6 @@ double homepi, /* value of pi calculated by current task */
pisum; /* sum of workers pi values */ pisum; /* sum of workers pi values */
int i, n; int i, n;
srandom (0); srandom (0);
avepi = 0; avepi = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment