#include <cstdio>
#include <ctime>
#include <omp.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 10040000
int A[N],f[N],LC[N],RC[N],ans[N],cnt;
int n;// length of sequence
int th;// number of thread
void output(int i)
{
if(i>=n) return;
output(LC[i]);
ans[cnt++]=A[i];
output(RC[i]);
}
int main ()
{
int i,root;
bool flag=false;
double f1,f2;
int T=12;
while(scanf("%d%d",&n,&th)!=EOF) // input the length of sequence and number of thread
{
cnt=0;
//generate the original sequence
srand(time(0));
for(i=0;i<n;++i) A[i]=rand();
time_t first,second;
first=clock();
omp_set_num_threads(th);
#pragma omp parallel private(i) shared(root)
{
#pragma omp for
for(i=0;i<n;++i)
{
root=i;// compete to be the root of the balance tree
LC[i]=RC[i]=n+1;
}
#pragma omp for
for(i=
openMP实现的快排
最新推荐文章于 2023-06-19 08:49:46 发布