-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
140 lines (100 loc) · 2.73 KB
/
main.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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//Library & Dependency Includes
#include <iostream>
#include <algorithm>
#include <vector>
//Main Function
int main(int argc, char **argv) {
//Declaring Variables:
int arSiz=0;
int repet=0;
float selInput = 0.0;
float average = 0.0;
float median = 0.0;
float finMed = 0.0;
float fashion = 0.0;
std::string ver = "0.2.1.1";
std::vector<float> vecVar;
std::cout << "\nStatistics Helper by Firebrnr\n version: " << ver << "\n\nInput your array size:\n\t\\-->";
std::cin >> arSiz;
std::cout <<"\n" << std::endl;
// -!_!- Getting Values:
for (float i = 0; i < arSiz; i++) {
std::cout << "\n\n" << "INSERT VALUE " << i + 1 << "\n\n\t\\-->>";
std::cin >> selInput;
vecVar.push_back(selInput);
std::cout << "Value: "<< selInput<<" inserted in slot:" << i << "\n";
}
std::cout << "\n\n";
std::cout << "Values withOUT Sorting: ";
//!!!Shows data in vecVar:
for (float i : vecVar) {
std::cout << " " << i << " ";
}
std::cout << "\n";
//Sorts the data:
sort(vecVar.begin(), vecVar.end());
//Enters new line:
std::cout << "\n";
// - SORTING PRINT -
//Prints simple text:
std::cout << "Values WITH Sorting: ";
//!!!Shows data in vecVar (the used vector):
for (float i : vecVar) {
std::cout << " " << i << " ";
}
std::cout << "\n\n";
// - MEDIAN PRINT -
// Prints simple text :
std::cout << "Median: ";
repet = 0;
//Checks if it is a pair vector
if (arSiz % 2 == 0) {
for (float i : vecVar) {
if (repet == ((arSiz-1) / 2)) {
median = median+=i;
}
if (repet == (((arSiz-1) / 2) +1)) {
median = median += i;
}
repet++;
}
finMed = (median/2);
}
else {
for (float i : vecVar) {
if (repet == (arSiz-1) / 2) {
median = median += i;
}
repet++;
}
finMed = (median / 2);
}
std::cout << finMed;
std::cout << "\n\n";
// - FASHION PRINT -3
// Prints simple text :
std::cout << "Fashion: ";
//!!!Shows data in vecVar (the used vector):
for (float i : vecVar) {
std::cout << " " << i << " ";
}
std::cout << "\n\n";
// - AVERAGE PRINT -
// Prints simple text :
std::cout << "Average: ";
//!!!Shows data in vecVar (the used vector):
for (float i : vecVar) {
average+=i;
}
average = average / arSiz;
std::cout << average;
std::cout << "\n\n";
// Prints simple text :
std::cout << "Range: ";
std::cout << vecVar.back() - vecVar.front();
//!!!Shows data in vecVar (the used vector):
std::cout << "\n\tSmallest Value: " << vecVar.front()<< "\n\tLargest Value: " << vecVar.back();
std::cout << "\n\n";
//return exit code 0 (no error):
return 0;
}