|
|
|
@ -7,33 +7,42 @@
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Input {
|
|
|
|
|
vector<double> numbers;
|
|
|
|
|
size_t bin_count{};
|
|
|
|
|
double USER_BIN_HEIGHT{};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Input input_data(istream& stream) {
|
|
|
|
|
Input input_data(istream& stream, bool prompt) {
|
|
|
|
|
|
|
|
|
|
size_t number_count;
|
|
|
|
|
|
|
|
|
|
size_t number_count;
|
|
|
|
|
if (prompt) {
|
|
|
|
|
cerr << "Enter number count: ";
|
|
|
|
|
}
|
|
|
|
|
stream >> number_count;
|
|
|
|
|
|
|
|
|
|
Input in;
|
|
|
|
|
|
|
|
|
|
if (prompt){
|
|
|
|
|
cerr << "Enter number of bins: ";
|
|
|
|
|
}
|
|
|
|
|
stream >> in.bin_count;
|
|
|
|
|
|
|
|
|
|
in.numbers.resize(number_count);
|
|
|
|
|
|
|
|
|
|
if (prompt){
|
|
|
|
|
cerr << "Enter numbers: ";
|
|
|
|
|
}
|
|
|
|
|
for (size_t i = 0; i < number_count; i++)
|
|
|
|
|
{
|
|
|
|
|
stream >> in.numbers[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prompt){
|
|
|
|
|
cerr << "Enter image height: ";
|
|
|
|
|
}
|
|
|
|
|
stream >> in.USER_BIN_HEIGHT;
|
|
|
|
|
|
|
|
|
|
return in;
|
|
|
|
@ -43,8 +52,9 @@ Input input_data(istream& stream) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
|
bool prompt= true;
|
|
|
|
|
|
|
|
|
|
Input in = input_data(cin);
|
|
|
|
|
Input in = input_data(cin, prompt);
|
|
|
|
|
|
|
|
|
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
|
|
|
|
|
|