-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayUtilities.c
More file actions
43 lines (40 loc) · 803 Bytes
/
arrayUtilities.c
File metadata and controls
43 lines (40 loc) · 803 Bytes
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
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/**
* Fill up the arrays with random numbers
*
* int array[]
* int arr_size
*
**/
void genArr(int array[], int array2[], int array3[], int array4[], int arr_size)
{
int i;
srand(time(NULL));
for (i = 0; i < arr_size; i++)
{
int nb = 0;
nb = rand() % arr_size;
array[i] = nb;
array2[i] = nb;
array3[i] = nb;
array4[i] = nb;
}
}
/**
* Swap values from array
*
* int array[] :: array where swap takes place
* int x :: index of the first value : bigger
* int y :: index of the second value : smaller
*
* return void
**/
void swap(int array[], int x, int y)
{
int tmp; //temporary variable to swap variables value
tmp = array[x];
array[x] = array[y];
array[y] = tmp;
}