-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
41 lines (38 loc) · 767 Bytes
/
main.cpp
File metadata and controls
41 lines (38 loc) · 767 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
#include <iostream>
#include "Sorter.h"
#include "Utilities.h"
void printArray(int[], int);
int main()
{
Sorter s;
Timer timer;
Utilities u;
int len = 20;
int t[len];
u.generateArray(t, len);
s.mergeSort(t, len);
printArray(t, len);
return 0;
}
void printArray(int arr[], int n)
/*
* Prints out an array in groups of 10 elements per line.
* arr[] is the array to be printed, and n is its length.
*/
{
int counter = 1;
for (int i = 0; i < n - 1; i++)
{
if (i == 0 || counter < 10)
{
std::cout << arr[i] << ", ";
counter++;
}
else
{
std::cout << arr[i] << "\n";
counter = 1;
}
}
std::cout << arr[n - 1] << "\n";
}