Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void nqueens(char *config, int n, int i)
- {
- char *new_config;
- int j;
- if (i==n)
- {
- #pragma omp atomic
- count++;
- }
- for (j=0; j<n; j++)
- {
- if (i < 1){
- new_config = malloc((i+1)*sizeof(char));
- memcpy(new_config, config, i*sizeof(char));
- #pragma omp task
- {
- if (safe(new_config, i, j))
- {
- new_config[i] = j;
- nqueens(new_config, n, i+1);
- }
- }
- #pragma omp taskwait
- free(new_config);
- }else{
- new_config = malloc((i+1)*sizeof(char));
- memcpy(new_config, config, i*sizeof(char));
- if (safe(new_config, i, j))
- {
- new_config[i] = j;
- nqueens_serial(new_config, n, i+1);
- }
- free(new_config);
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement