Родитель
8f0cc94d7b
Сommit
865618e393
@ -0,0 +1,2 @@
|
||||
/bin
|
||||
/obj
|
@ -0,0 +1,9 @@
|
||||
#ifndef HEAD_H_INCLUDED
|
||||
#define HEAD_H_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
|
||||
std::vector<size_t> make_histogram(const std::vector<double>& numbers, size_t bin_count);
|
||||
|
||||
#endif // HEAD_H_INCLUDED
|
||||
|
@ -0,0 +1,8 @@
|
||||
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
#define HISTOGRAM_INTERNAL_H_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
|
||||
void find_minmax(const std:: vector<double>& numbers, double& min, double& max)
|
||||
|
||||
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
@ -0,0 +1,42 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include "head.h"
|
||||
#include "text.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
struct Input {
|
||||
vector<double> numbers;
|
||||
size_t bin_count{};
|
||||
};
|
||||
|
||||
Input
|
||||
input_data() {
|
||||
size_t number_count;
|
||||
cin >> number_count;
|
||||
Input in;
|
||||
in.numbers.resize(number_count);
|
||||
|
||||
for (size_t i = 0; i < number_count; i++) {
|
||||
cin >> in.numbers[i];
|
||||
}
|
||||
|
||||
cout << "Enter number of bins";
|
||||
cin >> in.bin_count;
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
Input in = input_data();
|
||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||
show_histogram_text(bins, in.bin_count);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include "text.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void show_histogram_text(vector <size_t> bins, size_t bin_count ) {
|
||||
|
||||
for (size_t i = 0; i < bin_count; i++) {
|
||||
if (bins[i] < 100) {
|
||||
cout << " ";
|
||||
}
|
||||
if (bins[i] < 10) {
|
||||
cout << " ";
|
||||
}
|
||||
cout << bins[i] << "|";
|
||||
for (size_t j = 0; j < bins[i]; j++) {
|
||||
cout << "*";
|
||||
}
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
#ifndef TEXT_H_INCLUDED
|
||||
#define TEXT_H_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
|
||||
void show_histogram_text(std::vector <size_t> bins, size_t bin_count);
|
||||
|
||||
#endif // TEXT_H_INCLUDED
|
Загрузка…
Ссылка в новой задаче