-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
107 lines (95 loc) · 2.08 KB
/
Copy pathmain.c
File metadata and controls
107 lines (95 loc) · 2.08 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
107
#include "heap.h"
#define TH 1
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
int main() {
float arr1[M], temp, insertedNum;
database* data = NULL;
int i, option = 1;
int amount = 0;
while (amount < M) {
printf("\nPlease enter how many numbers you want to enter, it should be below %d numbers: ", M);
scanf("%d", &amount);
if (amount > M) {
printf("the number you entered is too big, please enter a number below %d", M);
amount = 0;
}
else
break;
}
for (i = 0; i < amount; i++) {
printf("\nEnter number: ");
scanf("%f", &temp);
arr1[i] = temp;
}
data = Init(&arr1, amount);
if (data == NULL) {
printf("\ncouldn't allocate memory and initializing the data. please try again later");
exit(1);
}
while (TH) {
fflush(stdin);
option = message();
switch (option) {
case 1: {//find min
if (data->dataBaseSize == 0) {
printf("There are not numbers in the databse");
}
else {
printf("\nThis is the minimum value: %f", Find_min(data));
}
break;
}
case 2: { //find max
if (data->dataBaseSize == 0) {
printf("There are not numbers in the databse");
}
else {
printf("\nThis is the maxmimum value: %f", Find_max(data));
}
break;
}
case 3: {//Insert
if (data->dataBaseSize < M) {
printf("\nPlease enter a number that you want to enter the database: ");
scanf("%f", &insertedNum);
Insert(data, insertedNum);
}
else {
printf("\nThere are too many numbers in the database, please delete some before insertting any more");
}
break;
}
case 4: {//Del MIN
if (data->dataBaseSize > 0) {
Del_Min(data);
}
else {
printf("\nThere are no numbers in the database");
}
break;
}
case 5: {
if (data->dataBaseSize > 0) {
Del_Max(data);
}
else {
printf("\nThere are no numbers in the database");
}
break;
}
case 6: {
printf("Exiting program.. See Ya");
exit(1);
break;
}
default: {
if (option < 1 || option > 6)
printf("You entered wrong option. Please enter values '1-6' Thank you");
break;
}
}
}
return 0;
}