Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#define SIZE 10000
void swap(int *xp, int *yp);
void sort(int arr[], int size);
// Function prototypes for thread tasks
// TODO: Declare functions for calculating mean and median
int main() {
int arr[SIZE];
for(int i = SIZE - 1; i >= 0; i--)
arr[(SIZE - 1) - i] = i % 2;
// TODO: Implement your solution here
// TODO: Create threads for calculating mean and median
// TODO: Display the result (mean, median)
// TODO: Print TIDs of involved threads
return 0;
}
void swap(int *xp, int *yp) {
int temp = *xp;
*xp = *yp;
*yp = temp;
}
void sort(int *arr, int size) {
for (int i = 0; i < size - 1; i++)
for (int j = 0; j < size - i - 1; j++)
if (arr[j] > arr[j + 1])
swap(&arr[j], &arr[j + 1]);
}