-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
35 lines (27 loc) · 884 Bytes
/
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
#include <iostream>
#include <vector>
constexpr int MINIMUM{ -99 };
constexpr int MAXIMUM{ 100 };
constexpr int INTERVALNUMBER{ 10 };
constexpr int INTERVALWIDTH{ (MAXIMUM - MINIMUM + 1) / INTERVALNUMBER };
int main()
{
int input;
std::vector<int> intervals(INTERVALNUMBER);
std::cout << "Only integers" << '\n';
std::cout << "Please enter a number in range of " << MINIMUM << "..." << MAXIMUM << ": ";
std::cin >> input;
while(input >= MINIMUM && input <= MAXIMUM)
{
intervals.at((input - MINIMUM) / INTERVALWIDTH)++;
std::cin >> input;
}
std::cout << '\n';
for (int i = 0; i < INTERVALNUMBER; ++i)
std::cout << "Interval " << i * INTERVALWIDTH + MINIMUM << " .. " << (i + 1) * INTERVALWIDTH + MINIMUM - 1 << ": " << intervals.at(i) << '\n';
std::cout << '\n';
std::cout << "Press Enter to continue . . . ";
std::cin.ignore();
std::cin.get();
return 0;
}