#include <iostream>
#include <algorithm>
#include <functional>
#include <thread>
int main(int argc, const char * argv[]) {
unsigned int threads;
unsigned int vectorSize;
void mergesort(int[], int, int );
void merge(int[], int, int, int );
const int n = 8;
int a[n] = {10, 3, 15, 2, 1, 4, 9, 0};
int i;
mergesort(a, 0, n-1);
for(i=0; i<n; i++)
{
std::cout<< a;
}
return 0;
}
#include "Parallel.h"
typedef int Item;
void merge(int a[], int left, int right )
{
int center;
if(left<right)
{
center= (left+right)/2;
mergesort(a, left, center );
mergesort(a, center+1, right );
merge(a, left, center, right );
}
}
void merge(int a[], int left, int center, int right)
{
int i, j, k;
int b[8];
i = left;
j = center+1;
k = 0;
//fusione delle 2 meta'
while ((i<=center) && (j<=right))
{
if (a <= a[j])
{
b[k] = a;
i++;
}
else
{
b[k] = a[j];
j++;
}
k++;
}
while (i<=center)
{
b[k] = a;
i++;
k++;
}
while (j<=right)
{
b[k] = a[j];
j++;
k++;
}
for (k=left; k<=right; k++)
{
a[k] = b[k-left];
}
}