-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.c
More file actions
106 lines (98 loc) · 2.49 KB
/
Main.c
File metadata and controls
106 lines (98 loc) · 2.49 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "StrList.h"
#define MAX 100
int main()
{
int option = 0;
int wordsamount = 0;
int index;
char word[MAX];
StrList *list = StrList_alloc();
do{
// Get user input for option
scanf("%d", &option);
// Switch case for 14 options
switch (option)
{
case 0:
break;
case 1:
// Code for option 1
scanf("%d", &wordsamount);
for (size_t i = 0; i < wordsamount; i++)
{
scanf("%s", word);
StrList_insertLast(list, word);
}
break;
case 2:
// Code for option 2
scanf("%d", &index);
scanf("%s", word);
StrList_insertAt(list, word, index);
break;
case 3:
// Code for option 3
StrList_print(list);
printf("\n");
break;
case 4:
// Code for option 4
printf("%zu \n", StrList_size(list));
break;
case 5:
// Code for option 5
scanf("%d", &index);
StrList_printAt(list, index);
break;
case 6:
// Code for option 6
printf("%d \n", StrList_printLen(list));
break;
case 7:
// Code for option 7
scanf("%s", word);
printf("%d \n", StrList_count(list, word));
break;
case 8:
// Code for option 8
scanf("%s", word);
StrList_remove(list, word);
break;
case 9:
// Code for option 9
scanf("%d", &index);
StrList_removeAt(list, index);
break;
case 10:
// Code for option 10
StrList_reverse(list);
break;
case 11:
// Code for option 11
while (StrList_size(list) > 0)
StrList_removeAt(list, 0);
//StrList_free(list);
break;
case 12:
// Code for option 12
StrList_sort(list);
break;
case 13:
// Code for option 13
if (StrList_isSorted(list))
printf("true\n");
else
printf("false\n");
break;
default:
printf("Invalid option\n");
break;
}
}
while (option != 0);
StrList_free(list);
return 0;
}