From 0b40695ba8f437fbbd933240320fef9da16163b5 Mon Sep 17 00:00:00 2001 From: GordiyevskikDA Date: Tue, 5 Mar 2024 20:21:52 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B3=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LABA1.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/LABA1.cpp b/LABA1.cpp index d11a2ef..e490ab1 100644 --- a/LABA1.cpp +++ b/LABA1.cpp @@ -8,8 +8,7 @@ struct Input { int NCharts = 0; }; -Input -input_data() { +Input input_data() { Input in; int VecSize = 0; cin >> VecSize; @@ -21,22 +20,19 @@ input_data() { return in; }; -int main() -{ +void show_histogram_text(const vector& marks, const vector& chart) { + int VecSize = size(marks); const int shift = 4, maxlen = 80; - Input in = input_data(); - int VecSize = size(in.marks); double interval = 0, inp = 0, i = 0, min = 0, max = 0, scale = 1; - vector chart = MakeHistogram(in.marks, in.NCharts); FindMinMax(chart, min, max); - if ((max+shift) > maxlen) { - scale = (max+shift) / maxlen; + if ((max + shift) > maxlen) { + scale = (max + shift) / maxlen; } - for (i = 0; i < in.NCharts; i++) { + for (i = 0; i < size(chart); i++) { if (chart[i] < 10) { cout << " "; } - else if (9 < chart[i] && chart[i]< 100) { + else if (9 < chart[i] && chart[i] < 100) { cout << " "; } cout << chart[i] << "|"; @@ -49,4 +45,11 @@ int main() } cout << "\n"; } +}; + +int main() +{ + Input in = input_data(); + vector chart = MakeHistogram(in.marks, in.NCharts); + show_histogram_text(in.marks, chart); } \ No newline at end of file