- Code: Select all
`# include <stdlib.h>`

# include <stdio.h>

# include <omp.h>

#define N 10

int main()

{

int x[N], y[N];

int i, j,k, my_num, my_place,startval,endval,rank;

for (k=0; k<N; k++)

{

x[k] = N - i;

y[k]=N-i;

}

#pragma omp parallel for private(i, j, startval, endval, rank) shared(x, y, N)

{

rank = omp_get_thread_num ( );

startval = N*rank/N+1;

endval = N*(rank+1)/N;

for (j=startval; j<endval; j++) {

my_num = x[j];

my_place = 0;

for (i=0; i<N; i++)

{

if ( my_num > x[i] )

my_place++;

}

y[my_place] = my_num;

}

}

for (i=0; i<N; i++)

printf("%d\n", y[i]);

return 0;

}

Does anyone has any idea for my compilation error;