-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort.cpp
36 lines (31 loc) · 849 Bytes
/
sort.cpp
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
#include "sort.h"
int main(int argc, char *argv[]){
/* Collection of input data. */
// If command line arguments are given, input is taken from command line.
if(argc > 1){
int size = argc - 1;
double inputArray[size];
for(int i = 0; i< size; i++)
inputArray[i] = atof(argv[i+1]);
Algorithm_selector(inputArray, size);
printArray(inputArray, size);
}
// Else if arguments are typed in or comes from a file.
else{
char opt;
puts("Input numbers from? Keyboard(k), File(f), Quit(q)");
scanf("%c", &opt);
getchar(); //To clear stdin.
if(opt == 'f' || opt == 'F')
FinputCollector();
else if(opt == 'k' || opt == 'K')
KinputCollector();
else if(opt == 'q' || opt == 'Q')
puts("See you again, have a good day.");
else{
puts("Unauthorized input source. Try again later.");
return 1;
}
}
return 0;
}