From 14a2f838607e3354906bb69c9a0ea047837139e8 Mon Sep 17 00:00:00 2001
From: "Alexander (AntonovichAN)" <AntonovichAN@mpei.ru>
Date: Sun, 29 Sep 2024 19:54:57 +0300
Subject: [PATCH] =?UTF-8?q?code:=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=203.1=20?=
 =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20?=
 =?UTF-8?q?=D0=BF=D1=80=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

---
 histogram.cpp |  1 +
 histogram.h   |  4 ++--
 main.cpp      | 33 ++-------------------------------
 text.cpp      | 38 ++++++++++++++++++++++++++++++++++++++
 text.h        |  9 +++++++++
 5 files changed, 52 insertions(+), 33 deletions(-)
 create mode 100644 text.cpp
 create mode 100644 text.h

diff --git a/histogram.cpp b/histogram.cpp
index 857de96..344f24d 100644
--- a/histogram.cpp
+++ b/histogram.cpp
@@ -1,4 +1,5 @@
 #include <vector>
+#include <iostream>
 #include "histogram.h"
 
 using namespace std;
diff --git a/histogram.h b/histogram.h
index 0d8dc8c..37cf761 100644
--- a/histogram.h
+++ b/histogram.h
@@ -3,7 +3,7 @@
 
 #include <vector>
 
-std::vector<size_t>
-make_histogram(const std::vector<double>& numbers, size_t bin_count);
+std::vector<std::size_t>
+make_histogram(const std::vector<double>& numbers, std::size_t bin_count);
 
 #endif // HISTOGRAM_H_INCLUDED
diff --git a/main.cpp b/main.cpp
index 4550c63..5a6b998 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,11 +1,11 @@
 #include <iostream>
 #include <vector>
 #include "histogram.h"
+#include "text.h"
 
 using namespace std;
 
-const size_t SCREEN_WIDTH = 80;
-const size_t MAX_ASTERISK = SCREEN_WIDTH - 4;
+
 
 struct Input {
     vector<double> numbers;
@@ -32,35 +32,6 @@ Input input_data() {
     return in;
 };
 
-void show_histogram_text(const vector<size_t> &bins){
-    size_t maxbin = bins[0];
-    for (size_t i=1; i < bins.size(); i++){
-        if (maxbin < bins[i]){
-            maxbin = bins[i];
-        }
-    }
-
-    if (maxbin <= MAX_ASTERISK){
-        for (size_t i = 0; i < bins.size(); i++) {
-            cout.width(4);
-            cout << bins[i] << "|";
-            for (size_t j = 0; j < bins[i]; j++) {
-                cout << "*";
-            }
-            cout << endl;
-        }
-    } else {
-        for (size_t i = 0; i < bins.size(); i++) {
-            cout.width(4);
-            cout << bins[i] << "|";
-            size_t height = static_cast<size_t>(MAX_ASTERISK * (static_cast<double>(bins[i]) / maxbin));
-            for (size_t j = 0; j < height; j++) {
-                cout << "*";
-            }
-            cout << endl;
-        }
-    }
-}
 int main(){
     Input in = input_data();
 
diff --git a/text.cpp b/text.cpp
new file mode 100644
index 0000000..bc947fc
--- /dev/null
+++ b/text.cpp
@@ -0,0 +1,38 @@
+#include <vector>
+#include <iostream>
+#include "text.h"
+
+using namespace std;
+
+const size_t SCREEN_WIDTH = 80;
+const size_t MAX_ASTERISK = SCREEN_WIDTH - 4;
+
+void show_histogram_text(const vector<size_t> &bins){
+    size_t maxbin = bins[0];
+    for (size_t i=1; i < bins.size(); i++){
+        if (maxbin < bins[i]){
+            maxbin = bins[i];
+        }
+    }
+
+    if (maxbin <= MAX_ASTERISK){
+        for (size_t i = 0; i < bins.size(); i++) {
+            cout.width(4);
+            cout << bins[i] << "|";
+            for (size_t j = 0; j < bins[i]; j++) {
+                cout << "*";
+            }
+            cout << endl;
+        }
+    } else {
+        for (size_t i = 0; i < bins.size(); i++) {
+            cout.width(4);
+            cout << bins[i] << "|";
+            size_t height = static_cast<size_t>(MAX_ASTERISK * (static_cast<double>(bins[i]) / maxbin));
+            for (size_t j = 0; j < height; j++) {
+                cout << "*";
+            }
+            cout << endl;
+        }
+    }
+}
diff --git a/text.h b/text.h
new file mode 100644
index 0000000..9a3bae6
--- /dev/null
+++ b/text.h
@@ -0,0 +1,9 @@
+#ifndef TEXT_H_INCLUDED
+#define TEXT_H_INCLUDED
+
+#include <vector>
+
+std::vector<std::size_t>
+show_histogram_text(const std::vector <std::size_t>& bins);
+
+#endif // TEXT_H_INCLUDED