-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
48 lines (36 loc) · 842 Bytes
/
main.c
File metadata and controls
48 lines (36 loc) · 842 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
44
45
46
47
48
/* Japhet M. Perez
21 September 2015
Alex Noguchi
CS 232
merge sort */
#include <stdio.h>
#include "functions.h"
#define MAX 25
int main(int argc, char *argv[]) {
int i;
int n[argc-2];
int length = argc - 2;
int beginning = 0;
char word[MAX];
for(i = 0; i < argc; i++) {
printf("%s ", argv[i]);
}
printf("\n");
for(i = 0; i < length; i++) {
sscanf(argv[i+2], "%d", &n[i]);
}
// this if statement checks to see what function I am calling in the second element of user input on the command line.
if(argv[1][0] == 'm') {
merge(n, beginning, length - 1);
}
else {
printf("The only acceptable word is merge. Type merge in.\n");
return;
}
printf("Sorted list in ascending order:\n");
for(i = 0; i < length; i++) {
printf("%d ", n[i]);
}
printf("\n");
return 0;
}