14 N2 = rand () % (MAX - 51) + 50;
15 step = rand () % 7 + 1;
17 printf ("N1 = %d\nN2 = %d\nstep = %d\n", N1, N2, step);
19 for (i = N1; i <= N2; i += step)
22 /* COUNTING UP (<). Fill in array 'b' in parallel. */
23 memset (b, 0, sizeof b);
24 #pragma omp parallel shared(a,b,N1,N2,step) private(i)
27 for (i = N1; i < N2; i += step)
31 /* COUNTING UP (<). Check that all the cells were filled in properly. */
32 for (i = N1; i < N2; i += step)
36 printf ("for (i = %d; i < %d; i += %d) [OK]\n", N1, N2, step);
38 /* COUNTING UP (<=). Fill in array 'b' in parallel. */
39 memset (b, 0, sizeof b);
40 #pragma omp parallel shared(a,b,N1,N2,step) private(i)
43 for (i = N1; i <= N2; i += step)
47 /* COUNTING UP (<=). Check that all the cells were filled in properly. */
48 for (i = N1; i <= N2; i += step)
52 printf ("for (i = %d; i <= %d; i += %d) [OK]\n", N1, N2, step);
54 /* COUNTING DOWN (>). Fill in array 'b' in parallel. */
55 memset (b, 0, sizeof b);
56 #pragma omp parallel shared(a,b,N1,N2,step) private(i)
59 for (i = N2; i > N1; i -= step)
63 /* COUNTING DOWN (>). Check that all the cells were filled in properly. */
64 for (i = N2; i > N1; i -= step)
68 printf ("for (i = %d; i > %d; i -= %d) [OK]\n", N2, N1, step);
70 /* COUNTING DOWN (>=). Fill in array 'b' in parallel. */
71 memset (b, 0, sizeof b);
72 #pragma omp parallel shared(a,b,N1,N2,step) private(i)
75 for (i = N2; i >= N1; i -= step)
79 /* COUNTING DOWN (>=). Check that all the cells were filled in properly. */
80 for (i = N2; i >= N1; i -= step)
84 printf ("for (i = %d; i >= %d; i -= %d) [OK]\n", N2, N1, step);
93 for (i = 0; i < 10; ++i)