From 3a43d263077a01172b131bb065de2c82c19a22b5 Mon Sep 17 00:00:00 2001 From: GordiyevskikDA Date: Wed, 6 Mar 2024 06:52:50 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=92=D1=8B=D0=BD=D0=BE=D1=81=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=87=D0=B0=D1=82=D0=B8=20=D0=B3=D0=B8=D1=81=D1=82=D0=BE?= =?UTF-8?q?=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B=20=D0=B2=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LABA1.cpp | 32 +++++--------------------------- text.cpp | 29 +++++++++++++++++++++++++++++ text.h | 8 ++++++++ 3 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 text.cpp create mode 100644 text.h diff --git a/LABA1.cpp b/LABA1.cpp index e490ab1..bce4e4f 100644 --- a/LABA1.cpp +++ b/LABA1.cpp @@ -1,8 +1,13 @@ #include #include #include "histogram.h" +#include "text.h" using namespace std; +/* +Забабахать show_histogram_text в отдельный файл +*/ + struct Input { vector marks; int NCharts = 0; @@ -20,33 +25,6 @@ Input input_data() { return in; }; -void show_histogram_text(const vector& marks, const vector& chart) { - int VecSize = size(marks); - const int shift = 4, maxlen = 80; - double interval = 0, inp = 0, i = 0, min = 0, max = 0, scale = 1; - FindMinMax(chart, min, max); - if ((max + shift) > maxlen) { - scale = (max + shift) / maxlen; - } - for (i = 0; i < size(chart); i++) { - if (chart[i] < 10) { - cout << " "; - } - else if (9 < chart[i] && chart[i] < 100) { - cout << " "; - } - cout << chart[i] << "|"; - max = (chart[i] / scale); - if (scale != 1) { - max -= 1; - } - for (int j = 0; j < max; j++) { - cout << "*"; - } - cout << "\n"; - } -}; - int main() { Input in = input_data(); diff --git a/text.cpp b/text.cpp new file mode 100644 index 0000000..8e7e29c --- /dev/null +++ b/text.cpp @@ -0,0 +1,29 @@ +#include "histogram.h" +using namespace std; + +void show_histogram_text(const vector& marks, const vector& chart) { + int VecSize = size(marks); + const int shift = 4, maxlen = 80; + double interval = 0, inp = 0, i = 0, min = 0, max = 0, scale = 1; + FindMinMax(chart, min, max); + if ((max + shift) > maxlen) { + scale = (max + shift) / maxlen; + } + for (i = 0; i < size(chart); i++) { + if (chart[i] < 10) { + cout << " "; + } + else if (9 < chart[i] && chart[i] < 100) { + cout << " "; + } + cout << chart[i] << "|"; + max = (chart[i] / scale); + if (scale != 1) { + max -= 1; + } + for (int j = 0; j < max; j++) { + cout << "*"; + } + cout << "\n"; + } +}; \ No newline at end of file diff --git a/text.h b/text.h new file mode 100644 index 0000000..77324a7 --- /dev/null +++ b/text.h @@ -0,0 +1,8 @@ +#ifndef TEXT_H_INCLUDED +#define TEXT_H_INCLUDED +#include "text.cpp" //Âîçìîæíî, êîñòûëü. Íî áåç ýòîãî íå ðàáîòàåò! +#include + +void show_histogram_text(const vector& marks, const vector& chart); + +#endif // TEXT_H_INCLUDED \ No newline at end of file