Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <omp.h>
- #define N 5
- int tab[10] = {4,8,16,25,0,3,2,5,9,10};
- int start, i, global_max, local_max;
- int main(void)
- {
- global_max = tab[0];
- #pragma omp parallel default(none), private(start, i, local_max), shared(tab, global_max)
- start=1;
- #pragma parallel for
- for(i=0;i<10;i++)
- {
- if(start==1)
- {
- local_max=tab[i];
- start=0;
- }
- if(tab[i]>local_max)
- {
- local_max=tab[i];
- }
- }
- #pragma critical
- if(local_max>global_max)
- {
- global_max=local_max;
- }
- printf("Max= %d", global_max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement