-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSort-Bubble.c
More file actions
37 lines (30 loc) · 904 Bytes
/
Sort-Bubble.c
File metadata and controls
37 lines (30 loc) · 904 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
/*
Program: Bubble Sort
Author name: Mohamed Jasim Pocha
Email: mohd.jas@gmail.com
Created: 2013-12-10
Last modified: 2013-12-10
*/
#include "sorthelper.c"
int main (int argc, char *argv[])
{
ARRAY_SIZE = atoi(argv[1]);
int array[ARRAY_SIZE];
register int i, ii;
init_array(array);
clock_t start, end;
double cpu_time_used;
start = clock();
for (i = 0; i < ARRAY_SIZE; i++)
{
for (ii = 0; ii < ARRAY_SIZE-i; ii++)
{
if (less(array, ii+1, ii)) { exch(array, ii, ii+1); }
}
}
print_array(array);
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("%f\n", cpu_time_used);
return 0;
}