code: Вынос расчёта диаграммы в отдельный файл

master
Данил Гордиевских 1 год назад
Родитель e7cebd0f14
Сommit 5fe3586d4d

@ -1,14 +1,6 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include "histogram.cpp" #include "histogram.h"
/*
Костыль!!!!!
#include "histogram.h" не работает, тем не менее, всё по методичке
работает только с #include "histogram.cpp"
разобраться!!!!!!!!
Вынести печать в show_histogram_text(), а его в отдельный cpp и h
*/
using namespace std; using namespace std;
struct Input { struct Input {

@ -1,5 +1,4 @@
#include "histogram.h" #include "histogram.h"
using namespace std; using namespace std;
void FindMinMax(const vector<double>& marks, double& min, double& max) { void FindMinMax(const vector<double>& marks, double& min, double& max) {
@ -15,7 +14,7 @@ void FindMinMax(const vector<double>& marks, double& min, double& max) {
} }
}; };
vector <double> MakeHistogram(const vector<double>& marks, int NCharts) { static vector <double> MakeHistogram(const vector<double>& marks, int NCharts) {
double interval = 0, i = 0, min = 0, max = 0; double interval = 0, i = 0, min = 0, max = 0;
vector<double> chart(NCharts); vector<double> chart(NCharts);
FindMinMax(marks, min, max); FindMinMax(marks, min, max);

@ -1,5 +1,6 @@
#ifndef HISTOGRAM_H_INCLUDED #ifndef HISTOGRAM_H_INCLUDED
#define HISTOGRAM_H_INCLUDED #define HISTOGRAM_H_INCLUDED
#include "histogram.cpp" //Возможно, костыль. Но без этого не работает!
#include <vector> #include <vector>
std::vector<double> MakeHistogram(const std::vector<double>& marks, int NCharts); std::vector<double> MakeHistogram(const std::vector<double>& marks, int NCharts);

Загрузка…
Отмена
Сохранить