-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
62 lines (52 loc) · 1.59 KB
/
main.c
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
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "table.h"
int main (void) {
char filename[10];
printf("Enter the name of file:\n");
scanf("%s", filename);
int str_amount=str_quantity(&filename[0]);
Str* table = table_create(filename,str_amount);
char action[4];
menu();
do
{
scanf("%3s", action);
if (!strcmp(action, "1")) {
table_print(table, str_amount);
} else if (!strcmp(action, "2")) {
table_check_sort(table, str_amount);
} else if (!strcmp(action, "3")) {
table_data_search(table, str_amount);
} else if (!strcmp(action, "4")) {
table_linear_sort(table, str_amount);
} else if (!strcmp(action, "5")) {
table_sort_random(table, str_amount);
} else if (!strcmp(action, "6")) {
table_reverse(table, str_amount);
} else if (!strcmp(action, "7")) {
menu();
} else if (!strcmp(action, "0")) {
table_destroy(&table, str_amount);
break;
} else {
printf("\nIncorrect input. Try another.\n");
}
} while (1);
return 0;
}
void menu(void)
{
printf("Menu:\n");
printf("1) Print the table\n");
printf("2) Check the sorting of the table\n");
printf("3) Search for the data by key\n");
printf("4) Sort the table\n");
printf("5) Shuffle the table\n");
printf("6) Reverse the table\n");
printf("7) Print menu \n");
printf("0) Exit\n");
printf("\nChose the action:\n");
}