фиксы и и histogram_internal.h
Этот коммит содержится в:
16
Header.cpp
16
Header.cpp
@@ -1,19 +1,5 @@
|
|||||||
#include "Header.h"
|
#include "Header.h"
|
||||||
Input input_data()
|
void static find_minmax(vector<double> vec, double& min, double& max) {
|
||||||
{
|
|
||||||
Input in;
|
|
||||||
size_t n, korz;
|
|
||||||
|
|
||||||
cerr << "Number of elem ";
|
|
||||||
cin >> n;
|
|
||||||
in.vec.resize(n);
|
|
||||||
for (size_t i = 0; i < n; i++)
|
|
||||||
cin >> in.vec[i];
|
|
||||||
cerr << "Enter bin count: ";
|
|
||||||
cin >> in.korz;
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
void find_minmax(vector<double> vec, double& min, double& max) {
|
|
||||||
min = vec[0];
|
min = vec[0];
|
||||||
max = vec[0];
|
max = vec[0];
|
||||||
for (double x : vec) {
|
for (double x : vec) {
|
||||||
|
|||||||
6
Header.h
6
Header.h
@@ -1,10 +1,4 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
struct Input {
|
|
||||||
vector<double> vec;
|
|
||||||
size_t korz{};
|
|
||||||
};
|
|
||||||
Input input_data();
|
|
||||||
void find_minmax(vector<double> vec, double& min, double& max);
|
|
||||||
vector<size_t> make_histogram(size_t number, vector<double> vec);
|
vector<size_t> make_histogram(size_t number, vector<double> vec);
|
||||||
|
|||||||
14
histogram_internal.cpp
Обычный файл
14
histogram_internal.cpp
Обычный файл
@@ -0,0 +1,14 @@
|
|||||||
|
#include "histogram_internal.h"
|
||||||
|
void find_minmax(vector<double> vec, double& min, double& max) {
|
||||||
|
min = vec[0];
|
||||||
|
max = vec[0];
|
||||||
|
for (double x : vec) {
|
||||||
|
if (x < min) {
|
||||||
|
min = x;
|
||||||
|
}
|
||||||
|
else if (x > max)
|
||||||
|
{
|
||||||
|
max = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
histogram_internal.h
Обычный файл
2
histogram_internal.h
Обычный файл
@@ -0,0 +1,2 @@
|
|||||||
|
#include "Header.h"
|
||||||
|
void find_minmax(vector<double> vec, double& min, double& max);
|
||||||
18
maincpp.cpp
18
maincpp.cpp
@@ -1,8 +1,24 @@
|
|||||||
#include "Header.h"
|
#include "Header.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
struct Input {
|
||||||
|
vector<double> vec;
|
||||||
|
size_t korz{};
|
||||||
|
};
|
||||||
|
Input input_data() {
|
||||||
|
Input in;
|
||||||
|
size_t n, korz;
|
||||||
|
|
||||||
|
cerr << "Number of elem ";
|
||||||
|
cin >> n;
|
||||||
|
in.vec.resize(n);
|
||||||
|
for (size_t i = 0; i < n; i++)
|
||||||
|
cin >> in.vec[i];
|
||||||
|
cerr << "Enter bin count: ";
|
||||||
|
cin >> in.korz;
|
||||||
|
return in;
|
||||||
|
}
|
||||||
int main() {
|
int main() {
|
||||||
auto in = input_data();
|
auto in = input_data();
|
||||||
auto bins = make_histogram(in.korz, in.vec);
|
auto bins = make_histogram(in.korz, in.vec);
|
||||||
show_histogram(bins);
|
show_histogram(bins);
|
||||||
|
|
||||||
}
|
}
|
||||||
Ссылка в новой задаче
Block a user